Behavior
The behavior of removing pagination when there are fewer than 2 pages of items to display is hard-coded and intentional. The paginate_links()
Codex entry details that the function’s primary purpose is to display pagination links for archive posts. An archive being a collection of items, it could be argued that a single item by itself does not constitute an archive.
At the same time I understand your motivation – enumerating singular items seems a redundant task at first glance, but it certainly has it’s applications in design.
Still, though, I must add that I feel it presents the end-user with data of little to no relevance to their interests – most visitors don’t tend to care that they’re on page 1 of 1. And if an archive is only ever to contain one item, then it would be far stranger to display pagination implying pages of items that will never exist.
Background
This behavior can be identified in the source for the paginate_links()
function at line 2628, wherein the function returns early if there are fewer than 2 pages of content.
Solutions
-
My personal approach would be to place the pagination in a
<div>
of
determinate height and maintain the function’s hard-coded behavior.
In this manner, pagination is still displayed only where necessary,
yet it’s absence will not muck up the rest of your layout. -
If it is absolutely necessary that the page number be displayed when
there’s only one page, Andrei’s suggestion to useis_paged()
to
conditionally display an alternative to the pagination is the way to
go. -
Write a custom function to output pagination links in the manner you desire
-
It is possible to create a hack that will achieve the desired effect
by spoofing the number pages of available before the call to
paginate_links()
, then removing the links to non-existent pages
from the function’s return value or via thepaginate_links
filter
hook – however, doing so likely takes much more time, effort, and
code than other solutions, and will likely be broken by a core update
sometime down the road.