1

How do I achieve a seamless permalink view between a related custom post types and custom taxonomy?

I have:
CT: news
CT category: All
CPT: news-post
Post instance: Test Post

I would like to be able have the following structure:

site.com/news/all | All news posts of category 'All' | this works site.com/news/all/test-post or site.com/news/test-post | to access the cpt instance tagged with 'All'

Tools I'm using:
Pods Framework
Avada Theme
Have my permalinks set up to: /%category%/%postname%/

What I've tried: CPT re-write to 'News' | this failed

The issue I'm finding is that if the CPT rewrite matches the CT slug it breaks. But if I alter the CPT re-write to say news-category, then it works, and my access to the post becomes: site.com/news-category/test-post, but this looks a bit strange side by side:

site.com/news/all site.com/news-categoryews/test-post

Anything I'm missing?

I'm trying to mimic a drupal site, and they have this exact structure working: site.com/news | All news site.com/news/test-post | an instance of a news post with title Test Post.

How do I achieve this?

  • 3
    The problem is that WordPress determines what to query by the URL pattern. Given the request site.com/news/something, can you tell me if something is a term or a post? You can't without looking for one and/or the other, and seeing which you get back. You'll have to hook into request parsing and do that work yourself, or alternately, add a rewrite rule for every term in your taxonomy, to override the more general rule to match your posts. – Milo Mar 19 '18 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.