WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 15 months ago

#14345 closed defect (bug) (fixed)

BUG: Changing permalinks to a custom structure returns 404 on custom post types

Reported by: der Owned by:
Milestone: 3.6 Priority: normal
Severity: normal Version: 3.0
Component: Permalinks Keywords: has-patch commit 3.6-early
Focuses: Cc:

Description

To replicate the bug, do this:

  • Create a custom post type
  • Enable permalinks with the following custom structure: /%category%/%postname%
  • Save the settings
  • Access your post's permalink: It will return a 404 page
  • Go to permalink settings again (don't change anything) and Save the settings again.
  • Access your post's permalink: It will go to the post.

If you save the first time, it's not registering the changes, unless you save the settings for the second time without making any changes.

Change History (15)

comment:1 nacin4 years ago

  • Keywords reporter-feedback added; permalinks 404 removed

How is the post type registering and flushing rules? This doesn't seem right. Rules get flushed on every request for options-permalink.php.

comment:2 dd323 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Closing as workdforme, In the event that this is still a problem, please re-open it with more details on the registration.

comment:3 nofearinc3 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

I want to report the same issue.

I have a custom post type book which is working as supposed to with the standard permalink structure '?book=aus-tranen-werden-kristalle'. Setting a permalink structure as /%postname%/ rewrites the URLs in the following manner: '/book/aus-tranen-werden-kristalle'. This URL is no more accessible and marked as 404.

Also, when featured image is introduced for that post type, it is displayed but with the incorrect template. I use different templates for custom post types and the book template is not applied here.

Calling the get_post_type() returns NULL or 'attachment'.

comment:4 dd323 years ago

Can you please post a minimal code sample which can be used to reproduce the problem? Specifically any code used for registering the post type, as well as flushing the rules.

While You're at it, check to see if it happens with no other plugins loaded.

comment:5 pavelevap3 years ago

  • Cc pavelevap@… added

Related #18040 ?

comment:6 dd323 years ago

Related #18040 ?

That's what I was thinking of actually.

nofearinc: does it work as expected if you Hit Save on the permalinks options page again? - If so, this can be closed as a duplicate of the above.

comment:7 SergeyBiryukov3 years ago

  • Milestone set to Awaiting Review

comment:8 wonderboymusic22 months ago

#21824 was marked as a duplicate.

comment:9 wonderboymusic22 months ago

  • Keywords needs-patch added; reporter-feedback removed
  • Milestone changed from Awaiting Review to 3.5

comment:10 wonderboymusic22 months ago

Related / possible fix = #9296

comment:12 nacin20 months ago

  • Keywords has-patch commit 3.6-early added; needs-patch removed
  • Milestone changed from 3.5 to Future Release

comment:13 helen19 months ago

  • Milestone changed from Future Release to 3.6

comment:14 nacin15 months ago

In 24060:

Redirect after save on options-permalink.php to ensure permalinks are fully flushed. fixes #9296. see #14345 for more.

comment:15 nacin15 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

I switched the two ticket references in [24060] — fixes #14345, see #9296 for more.

Note: See TracTickets for help on using tickets.