How to show Multiple Custom Post Types that share Custom Taxonomies

This is a sample query where the home page would show all custom post types that shared the custom taxonomy, “Front Page”

First, we set up our Custom Post Types in the theme’s function.php file. We will create post types called, “Blog”, “Biology”, “Biodiversity”, and “Filmmaking”.

Next we build our Custom Taxonomy called, “Front Page” that is shared by the four Custom Post Types. That way we can query all post types that have the custom tax, front page checked and show them on the front page of the website. Place the Custom Taxonomy after your Post Types function in your theme’s function.php file.

After building the Custom Taxonomy, we go and create one. You create it just like you create normal categories. Click on “Show on Front Page?”, now listed under each Custom Post Type, and create a new one called, “Front Page” and make sure it’s slug ends up being, “front-page”.
Creating a Custom Taxonomy
Custom Taxonomy Created

Now that we have all that created we can publish some posts. As a test go create one from each new custom post type and make sure to check the, “Show on Front Page” custom taxonomy that we created. Once we’ve done that we can query our posts like below:

Leave a Reply

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

64 + = 74