[wp-trac] [WordPress Trac] #34136: Allow register_post_type's rewrite to remove CPT slug

WordPress Trac noreply at wordpress.org
Tue May 30 21:49:24 UTC 2017


#34136: Allow register_post_type's rewrite to remove CPT slug
---------------------------+------------------------------
 Reporter:  BenRacicot     |       Owner:
     Type:  enhancement    |      Status:  new
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Rewrite Rules  |     Version:  4.3.1
 Severity:  normal         |  Resolution:
 Keywords:                 |     Focuses:
---------------------------+------------------------------

Comment (by BenRacicot):

 What if you're using pages as they are meant to be used? As the standard
 web page layout... and your CPT's are being used as a custom web page
 layout or content as I described:



   Anytime you create a CPT for use as a method of public facing content
 creation in web page format where the use is meant to be browsable by URL.
 SEO, prett(ier) URLs etc...



 Replying to [comment:6 moeloubani1]:
 > Well as an example if I'm working on a learning website that has courses
 I'd rather have /course-title/chapter-name/class-name than /course/course-
 title/chapter-name/class-name and you're right, I could just put them into
 pages but imagine I have 300 classes and 10 pages, want to assign pages to
 some categories and courses to others etc. Now my category list is huge
 and the queries that happen for the workshop include the pages as well and
 you'd have to add some sort of other logic to differentiate between the
 two.
 >
 > What adding a new post type does is gives you the organization to be
 able to show things in two areas, keeps things that aren't the same
 separate and helps when you're trying to query those things later, lets
 you add post type specific taxonomies, archives, etc etc. Sometimes you
 want all those benefits and you want the URLs to be a certain way and I
 think that CPTs should have the flexibility to support that.
 >
 > Replying to [comment:4 michael.ecklund]:
 > > I guess I don't understand why you wouldn't just use the built-in
 hierarchical Post Type (`page`) for that.
 > >
 > > Replying to [comment:3 drzraf]:
 > > > Use-case: we have restaurants and had to ''tweak'' the rewrite (cf
 OP) in order to have provide URL like:
 > > > {{{
 > > > /<city>/<slug>
 > > > }}}
 > > > rather than the much more cumbersome:
 > > > {{{
 > > > /restaurant/<city>/<slug>
 > > > }}}
 > > > That best represents the main goal of the website which has no value
 being artificially namespaced.
 > > >
 > > > We also have a couple of other CPT of less significance (and none of
 them is named after a city) so that conflict are not going to be an issue
 (or at least a minor issue in comparison to having clean URL)
 > > >
 > > > Having an officially-supported way to omit the CPT URL's segment
 would be appreciated.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34136#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list