1

I have a custom taxonomy which is called locations which is assigned to post types which are post and events.

What I am trying to figure out is how to rewrite the URL of the terms to also include the custom post types where it will still go to the same term archive template and without breaking the pagination.

For example, the default URL of the taxonomy term that I have right now is

/location/europe
/location/asia

This is fine but I also would like to add a URL that will be for both post types the taxonomy is assigned to like:

/post/location/europe
/event/location/europe

Basically, what I am trying to figure out is support and add an additional URL segment because right now, when I try /post-type/taxonomy/term, it goes to a 404 page.

Is there a chance to have the URLs

/taxonomy/term
/post-type/taxonomy/term

use the same taxonomy-term.php template file?

4
  • @Jeda Take a look at my answer to the question "Custom Post Type with Nested Taxonomy and Template Files". Commented Mar 18, 2018 at 17:07
  • Hi @MichaelEcklund, thank you! This is helping me get started. The only problem I have is that I followed everything from your answer but when I try domain.com/portfolio/category/<term-slug>/, it goes to a 404 page even if I already resaved my permalinks and when I try to access /category/<term-slug>/, I get the term.php content. Commented Mar 18, 2018 at 17:46
  • I've written a relevant blog article about that question and answer, which may possibly contain updated information. It's located at the bottom of my answer. Make sure that you flush permalinks, either via code, or visit the permalinks page in the backend and re-save. Please also make sure the templating code provided is accurately followed / replicated. Commented Mar 18, 2018 at 18:13
  • I followed the guide from your blog and I have flushed the permalink settings in the backend but I am still getting a 404 for the domain.com/portfolio/category/<term-slug>/. Also, this approach seem to break the pagination functionality. Commented Mar 18, 2018 at 19:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.