Make WordPress Core

Opened 8 years ago

Last modified 3 years ago

#38599 new enhancement

Allow verbose rewrite rules with custom post types

Reported by: smerriman's profile smerriman Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: needs-patch
Focuses: Cc:


Every time I create a custom post type (say, Book) I invariably want a structure like this:

/books/ - static page where I can write all sorts of overview content with all of the formatting provided by the theme's page template (not a basic post type archive)

/books/book-2/ - custom post type permalinks

This is possible by using a rewrite slug of books.

However, if someone then creates a subpage of books, they'll get a 404 error, full stop.

This has been around a long time, and many workarounds have been provided in trying to get verbose rules triggered, such as:

Rewrite rules underwent some major changes a while ago for improved performance (to get %postname% permastructures working well, then there were pretty attachment URLs, etc), which results in these workarounds no longer working. (Custom post type rules get inserted at a place which isn't easy to reorder and conflicts with other rules).

Instead, I have to keep using unique prefixes which make things look messy and confusing to visitors:

/book/book-1/ (even though there is no /book/ page on my site)

Having a nicer structure seems like a very common use case (especially given the number of search results you'll find about workarounds).

I'd like to suggest allowing custom post types to trigger verbose rules in a way that will work.

Change History (2)

This ticket was mentioned in Slack in #core by peterwilsoncc. View the logs.

3 years ago

#2 @chaion07
3 years ago

  • Component changed from Permalinks to Posts, Post Types
  • Keywords needs-patch added

Hello @smerriman thank you for reporting this. We apologize for the delay in replying. The team reviewed this ticket during a recent triage session. Based on the feedback received from we made the following changes:

  1. Moving to the Post, Post Types component so that it can attract more attention from other people.
  2. Adding keyword needs-patch


Props to @mamaduka @peterwilsoncc @toro_unit @mikeschroder

Note: See TracTickets for help on using tickets.