Search code examples
wordpressposttaxonomy

Loop through custom post type based on value of taxonomy


I have a custom post type FAQ and custom taxonomy Category.

I want to loop through the taxonomy Category, take its values, and then loop through custom post type FAQ and grab all the posts that have the same taxonomy values.

Can anyone shed some light on this ?

Can't find any decent samples online that are trying to do what I want, only the opposite.

Cheers, Dave


Solution

  • Figured it out :) Would just like to share the answer :)

    $taxonomy_loop = new WP_Query( array( 'taxonomy_name_here' => $taxonomy_value ) );
    

    Where $taxonomy_value represents the value you are searching for. Regards, Dave