• I have a custom post type for contact directories with a custom taxonomy called “coach”. Regular posts have categories with names matching the “coach” taxonomy. For instance, the basketball coach is marked as basketball under the coach custom taxonomy. On the contact directory for the basketball coaches, I want to show posts for the “basketball” category. Is there a good way to get this done? I don’t want to add the categories to the contact directory, because I don’t want the contacts to show up with the news.

    Thanks!

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Sounds like you need to run two loops on the contact directory. The main loop to show the usual contacts of a particular term in the coach taxonomy. Then make a new query for the second loop using the term name of the coach taxonomy (i.e basketball) as a category parameter for this new regular posts query.

    Even if you were to add the categories taxonomy to the custom post type, the news page would query for a particular category and the post post type, so contacts would not show up anyway unless you modified the news query to show either post type. This characteristic is one reason to run two loops, though you could likewise specify both post types on the contacts query but not the news query in order to stay with one loop.

    There are often several ways to do something, deciding on the best can lead to headaches 🙂

Viewing 1 replies (of 1 total)

The topic ‘custom taxonomy template show related posts’ is closed to new replies.