get_pagenum_link() bug?
-
I am having problems with get_pagenum_link() and I’m wondering if this could be a bug.
The problem is that in theory the following code:
get_pagenum_link(3);
should return the URL for the the third page. Something like this:
https://www.mysite.com/?page=3
or this
https://www.mysite.com/page/3
Depending on your permalink structure.The function does what it is supposed to do as long as I have “pretty” permalinks enabled. In that case it returns the correct URL for the third page.
The problem only arises when WordPress is setup to use the default permalink structure. “https://www.mysite.com/?page=3”
In this case get_pagenum_link(3); maintains the “?page=” argument of the page you are currently viewing and then appends “?paged=”.
So, for example, if I am on page 6 and I call
get_pagenum_link(3);
instead of getting the URL for page 3. Something like this:
https://www.mysite.com/?page=3
I get this:
https://www.mysite.com/?page=6&paged=3
- The topic ‘get_pagenum_link() bug?’ is closed to new replies.