Make WordPress Core

Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#5331 closed defect (bug) (invalid)

Category pagination permalinks broken

Reported by: AnkurKothari Owned by:
Milestone: Priority: normal
Severity: minor Version: 2.5
Component: General Keywords: pagination category permalink 2nd-opinion
Focuses: Cc:


Using pretty permalinks (such as http://exampleblog.com/catname/post-slug), category pages can be reached via http://exampleblog.com/catname, but the pagination links point to http://exampleblog.com/catname/page/x, instead of http://exampleblog.com/category/catname/page/x.

Change History (7)

#1 @foolswisdom
10 years ago

  • Milestone changed from 2.3.2 to 2.5
  • Version set to 2.3.1

#2 @mtekk
9 years ago

  • Version changed from 2.3.1 to 2.5

Reproduced in 2.5. Seems to be caused by get_pagenum_link() not returning a valid permalink. Either in get_pagenum_link() we could check to see if it's a category and force the links to have the category/ in them, or just force a redirect from the url without category/ in it to having one. The only way that I've found a link to a "broken" category page is when I manually entered it without the category/ in the URL.

#3 @jhodgdon
9 years ago

  • Keywords 2nd-opinion added

I tried to test this today. I couldn't reproduce it. How did you do it, mtekk?

I actually have the same permalink structure in my 2.5.1 blog -- the permalink setting is:


which gives post URLs as described above ([blogurl]/[catname]/[postslug]).

However, my category URLs are the default [blogurl]/category/[catname], not [blogurl]/[catname] -- I think you have to have a category base (mine is the default "category"). What are you using there? I don't think the URLs will work correctly without a category base.

So in my blog, the navigation links generated by posts_nav_link at the bottom of my category pages are correct. The posts_nav_link function calls get_pagenum_link to figure out its link URLs, so it appears to be working in my blog.

So can you (a) check about the category base in your blog and (b) verify again that it isn't working?

#4 @mtekk
9 years ago

Ok here is the step by step on how I reproduced this, I can confirm these steps work with r8052

For permalinks you must use a custom structure of:

Now, select any of your categories that span multiple pages, the quickest way of doing this is navigating to it and then in your address bar remove the "/category" (this is a literal, not a variable related to your category of choice) press return. The page should load, just like the previous category page, except, low and behold, if you check out your next/previous page links they are different, if you click them they do not work (you get a 404).

Again I can only reproduce this by manually entering URLs, everything WordPress normally generates is perfectly fine. I get the same results using the permalink scheme:

#5 @jhodgdon
9 years ago

  • Resolution set to invalid
  • Severity changed from major to minor
  • Status changed from new to closed

[blog name]/[cat name] should also be generating a 404. The proper URL for that page is [blog name]/category/[cat name], as generated by WordPress. I am not sure why, if you manually edit out the /category in the URL, it is working at all as a URL, but that is a separate issue (you can file a bug on it if you want).

The fact that url [blog home]/[cat name]/page/2/ is a 404 is not a bug, since the URL to that page should be [blog home]/category/[cat name]/page/2/.

So I am provisionally closing this as "invalid", since you have to manually put in an invalid page URL in order to trigger it.

#6 @jhodgdon
9 years ago

Actually, I think that the reason that bad URL works at all is that

[blog home]/[cat name]

is being interpreted as the first part of a

[blog home]/[cat name]/[post slug]

permalink, with no post slug. It should be canonically redirected to [blog name]/category/[cat name] I think, just as it is when you do [blog home]/?cat=[ID] . I will file a bug on that... See #7101

#7 @thee17
9 years ago

  • Milestone 2.6 deleted
Note: See TracTickets for help on using tickets.