Archives for shared categories between Posts and Custom Post Types

Let’s say we are creating a Custom Post Type called Hotel, and we want it to share Categories with our Blog Posts, in order to show both on the Categories Archives.

In such a scenario, instead of assigning a Custom Taxonomy to our Hotel Post Type (something that is also available in WordPress, using a template file called taxonomy-{custom-slug}.php ) we want our Hotels to appear when category.php  is called.

To do it, we’ll have to open our functions.php  and add the following code at the end:

 

Credits go to: https://premium.wpmudev.org/blog/add-custom-post-types-to-tags-and-categories-in-wordpress/

Other infos, like targeting a particular Post Type and not all of them, are available there.

0 Give it a like!

Leave a Reply

Your email address will not be published. Required fields are marked *