Learn in this tutorial how to get WordPress to display the same design in a taxonomy as in the CPT archive pages by code.
If you have created a CPT with a taxonomy or use a plugin that supports it, it is likely that you will want to display it with the same structure that you have chosen for the archive page (for example, in grid format).
Do you want to save the step of creating a new template just for this?
Then use the conditional tags and tell WordPress to use the existing one.
Here are the exact instructions:
Snippet to redirect the taxonomy to a CPT archive template
Add the following code at the end of functions.php or in your functionality plugin:
To see this and another 1097 code snippets of this website, login or subscribe here.
It’s as simple as that. Now when you visit the taxonomy of a CPT the template you use for the archive page of the CPT will be loaded.
In the previous code you have the example CPT “portfolio”, but you can change both the CPT and the taxonomy to suit your needs.
Conclusion
As you can see, with a few lines of code you can save yourself from having to create a new template for your CPT taxonomy.
Any questions? I read you in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉