Skip to main content
1 of 11
birgire
  • 67.8k
  • 7
  • 119
  • 251

I took a look at the paginate_links() source code (v3.5.1) and there is this line

$link = str_replace('%_%', 1 == $n ? '' : $format, $base);

that is giving the empty string for the n=1 page.

With $base = "%_%" and $format = "http://example.com/page/%#%/" this becomes:

$link = str_replace('%_%', 1 == $n ? '' : "http://example.com/page/%#%/", "%_%");

Here is an example of the output from paginate_links():

<ul class='page-numbers'>
    <li><a class="prev page-numbers" href="http://example.com/page/2/">&laquo; Previous</a></li>
    <li><a class='page-numbers' href=''>1</a></li>
    <li><a class='page-numbers' href='http://example.com/page/2/'>2</a></li>
    <li><span class='page-numbers current'>3</span></li>
    <li><a class='page-numbers' href='http://example.com/page/4/'>4</a></li>
    <li><a class='page-numbers' href='http://example.com/page/5/'>5</a></li>
    <li><a class='page-numbers' href='http://example.com/page/6/'>6</a></li>
    <li><a class="next page-numbers" href="http://example.com/page/4/">Next &raquo;</a></li>
</ul>

But if this would be like:

$link = str_replace('%_%', $format, $base);

then the output of paginate_links() would be:

<ul class='page-numbers'>
    <li><a class="prev page-numbers" href="http://example.com/page/2/">&laquo; Previous</a></li>
    <li><a class='page-numbers' href='http://example.com/page/1/'>1</a></li>
    <li><a class='page-numbers' href='http://example.com/page/2/'>2</a></li>
    <li><span class='page-numbers current'>3</span></li>
    <li><a class='page-numbers' href='http://example.com/page/4/'>4</a></li>
    <li><a class='page-numbers' href='http://example.com/page/5/'>5</a></li>
    <li><a class='page-numbers' href='http://example.com/page/6/'>6</a></li>
    <li><a class="next page-numbers" href="http://example.com/page/4/">Next &raquo;</a></li>
</ul>

So it looks to me that this is empty by design, at least with your setup ;-)

birgire
  • 67.8k
  • 7
  • 119
  • 251