[wp-trac] [WordPress Trac] #38599: Allow verbose rewrite rules with custom post types

WordPress Trac noreply at wordpress.org
Tue Nov 1 00:08:42 UTC 2016


#38599: Allow verbose rewrite rules with custom post types
-------------------------+-----------------------------
 Reporter:  smerriman    |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Permalinks   |    Version:
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 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-1/
 /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:
 https://gist.github.com/mattberridge/2960966

 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:

 /books/
 /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.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38599>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list