Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#21748 closed defect (bug) (duplicate)

get_pagenum_link() returns URL with pagination base for a singular paged content

Reported by: szepe.viktor Owned by: wonderboymusic
Milestone: Priority: normal
Severity: major Version:
Component: Permalinks Keywords: has-patch
Focuses: Cc:


on this page I use an own plugin by a shortcode:


get_pagenum_link(2); returns


but it should make a difference:
front page: http://www.online1.hu/page/2/
other pages: http://www.online1.hu/webdesign/2/

Is it as bug??

Attachments (1)

pagenum-cases.diff (1.1 KB) - added by wonderboymusic 3 years ago.

Download all attachments as: .zip

Change History (11)

#1 @szepe.viktor
3 years ago

  • Cc szepe.viktor added

#2 @szepe.viktor
3 years ago

my front page is a static page,
links are: /%year%/%monthnum%/%postname%/

Last edited 3 years ago by szepe.viktor (previous) (diff)

#3 @szepe.viktor
3 years ago

so "page_on_front"

#4 @szepe.viktor
3 years ago

four cases

URLs : get_query_var(), content relative to !--nextpage--

in case of the front page
/2/ : HTTP/404
/page/2/ : paged= page=2, after !--nextpage-- content

in case of a page
/2/ : paged=0 page=2, after !--nextpage-- content
/page/2/ : paged=2 page=, before !--nextpage-- content

Last edited 3 years ago by szepe.viktor (previous) (diff)

#5 @wonderboymusic
3 years ago

  • Keywords has-patch added

get_pagenum_link() shouldn't use $wp_rewrite->pagination_base on single posts

#6 @duck_
3 years ago

wp_link_pages() is the appropriate function to use for getting paged links for paginated posts as get_pagenum_link() is designed for archive pagination.

Supporting singular pagination in get_pagenum_link() as well might be a good idea though. However, looking at the patch (untested) it looks like it doesn't support pages. So, should it be checking is_singular() and not page_on_front, see _wp_link_page()?

#7 @wonderboymusic
3 years ago

the default condition is everything else, including pages

#8 @wonderboymusic
3 years ago

  • Owner set to wonderboymusic
  • Status changed from new to accepted

Patch refreshed to account for 1) search 2) posts / pages except for page on front 3) everything else

#9 @wonderboymusic
3 years ago

Note: wp_link_pages() calls _wp_link_page() which is similar to get_pagenum_link()

#10 @wonderboymusic
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from accepted to closed

Duplicate of #4463.

This is insane - I patched 2 different tickets and the diff was almost exactly the same. This one's a dupe then.

Note: See TracTickets for help on using tickets.