I’ve been looking around for half a day now but no success so far.
I’ve created a custom post type (recipe) and two custom taxonomies that go with it (type and cook). What I want is to be able to list all “cooks” from a group of recipes.
I can do it for a single recipe but I’m stuck with multiple ones.
Does anyone have any idea on how to achieve this?
For each post add each term to a PHP associative array:
Let’s say Bob was listed as the cook on the first two recipes. When the first post is processed a field named
Bob
is added to$terms_list
. On the second post theBob
field is overwritten with the same information (a term object).The result after looping through all posts is a list
key => values
where the keys are unique. Bob, for example, is only listed once.Since you didn’t provide any code or tell us what you wanted the output should look like, I made this example up using the
get_posts()
function to get the array of posts and used an unordered list to display the cooks names as links.