Support » Fixing WordPress » query custom taxonomy based on post ID

  • hey all;

    here’s what i’m trying to do.

    – i have a custom post type (CPT) which has custom taxonomies (web, print, video, custom).
    – each custom post has a custom taxonomy associated with it, as well as a featured image.
    – i am creating a grid of the featured images (basically a gallery) for each taxonomy.
    – i have a page, called design that calls the different taxonomies based on user interaction.
    – the hierarchy is ~/design/taxonomy (web, print, video, custom)

    i have code that will display the images, but currently only for a specific taxonomy, by using this code

    <ul class="feat-imgs">
    <?php $loop = new WP_Query( array( 'package_types' => 'web', 'posts_per_page' => 6 ) );
    while ( $loop->have_posts() ) : $loop->the_post();
     echo '<li>';the_post_thumbnail($loop->ID);
     echo '</li>';
    endwhile; ?>

    can anyone help me modify this code to get the custom loop to grab the taxonomy ID in this line

    $loop = new WP_Query( array( 'package_types' => 'web', 'posts_per_page' => 6 ) );

    instead of having to hardcode the 'package_types' => 'web'??

    it might also be worth noting that this code sits inside a standard Loop.

    any help is appreciated.

  • The topic ‘query custom taxonomy based on post ID’ is closed to new replies.