• Resolved jonasverhulst

    (@jonasverhulst)


    Dear,

    We want to link our custom post types to a parent page. To get the right breadcrumbs, we want to implement the following rewrite slug :

    ‘rewrite’ => array(‘slug’ => ‘case-studies’, ‘with_front’ => true)

    I guess we can enter this in the Custom Rewrite Slug field, but I am not sure in which way. Can you help?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I believe I undid the forced underscores for post type slugs, so if your slug is already case-studies for the post type, then you shouldn’t need to do anything for the custom rewrite slug. If it’s case_studies, casestudies or something similar, then you’d want to add in case-studies for the rewrite slug. Everything else should fall in place like expected.

    Thread Starter jonasverhulst

    (@jonasverhulst)

    Hi @tw2113 ,

    Thank you for your response.

    We want to create the following situation. We have a custom post type names Case Studies with slug ‘case_studies’. We added a custom field allowing to link the post to a page, with the idea of that page being a parent page. The parent page has ex. slug ‘studies’.

    For a post link, now we want it to be /studies/postname instead of /case_studies/postname.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Now things are getting complex.

    The various parts of the permalink are actually pretty important. Also you can’t create hierarchies across post types, including pages.

    My first question is what is being shown on the PAGE studies right now?

    Asking because I’m wondering if you could get by with a post type of studies instead of a page named that, and then posts in that post type, giving you /studies/postname permalinks.

    If studies is left as a PAGE, and then trying to get the CPTs referenced under it, chances are that postname in those cases would be interpreted as a child PAGE and not a post type post.

    I have to believe you could make use of archive-studies.php to handle the content on .com/studies/ permalink, if there is stuff there, and you could even set things up to query for a specific page content/post content so that you still get an editor experience for editing that content. Just a matter of getting a little creative.

    Thread Starter jonasverhulst

    (@jonasverhulst)

    The ‘studies’ is just one example. In fact the CPT ‘case_studies’ will be linked to different pages, depending on the post.

    Ex. Post A linked to page /studies/
    Post B linked to page /concepts/

    In fact we are creating child pages via the CPT to these linked pages. There are various reasons for doing like this, one of them being the data for the CPT is loaded via an API and we don’t want to mix it up with our regular Pages.

    The systems works good, except for the permalink structure which is currently not displaying the parent-child relation.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I definitely get not wanting to mix content types, which is part of the infinite charm of post types.

    The headaches come from when different content types need to be all represented in one URL. First part is a slug from an existing PAGE, second part being from an existing STUDIES post type, third part being a post in the STUDIES post type. Along with any other combination of potential url parts. It’s all how WordPress parses and tries to determine what it should be querying for.

    You know your situation more than I do, but I am wondering if you couldn’t push that API data into post type posts instead of standard pages. However, that could also end up changing what URL those parts get accessed from as well, so may not be as desirable either.

    Custom Post Type UI only really handles registration of the content types, and majority of the parameters around that. We don’t have any functionality around permalink customization as a whole, outside of “what rewrite slug value should we register for this post type”. That said, I’ve long taken the stance of help out when/where I can to at least point users in the right direction.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Rewrite slug for custom post type parent page’ is closed to new replies.