snipt

Ctrl+h for KB shortcuts

PHP

Control Wordpress posts per page

1
2
3
4
5
6
    <?php
$page_num = $paged;
if ($pagenum='') $pagenum =1;
query_posts('showposts=20&paged='.$page_num); ?>
         
    
https://snipt.net/embed/d1230e43e996fccde11a5dfb423aed02/
/raw/d1230e43e996fccde11a5dfb423aed02/
d1230e43e996fccde11a5dfb423aed02
php
PHP
6
2019-07-21T04:55:53
True
False
False
Aug 16, 2012 at 09:09 AM
/api/public/snipt/45775/
control-wordpress-posts-per-page
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x"> </span><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="nv">$page_num</span> <span class="o">=</span> <span class="nv">$paged</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="k">if</span> <span class="p">(</span><span class="nv">$pagenum</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">)</span> <span class="nv">$pagenum</span> <span class="o">=</span><span class="mi">1</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a><span class="nx">query_posts</span><span class="p">(</span><span class="s1">&#39;showposts=20&amp;paged=&#39;</span><span class="o">.</span><span class="nv">$page_num</span><span class="p">);</span> <span class="cp">?&gt;</span><span class="x"></span> </span><span id="L-5"><a name="L-5"></a><span class="x"> </span> </span><span id="L-6"><a name="L-6"></a><span class="x"> </span> </span></pre></div> </td></tr></table>
Wordpress, loop, php, posts