WordPress.org

Ready to get started?Download WordPress

Forums

query_tax for all images in posts (1 post)

  1. anthonyabraira
    Member
    Posted 1 year ago #

    I see that there are numerable forum threads where people discuss getting all the images from a single post.

    In this case I am trying to:

    1. query for all posts that have a certain taxonomy ( in this case: projects )
    2. then show all of the attached images from ALL these posts in a slideshow

    This is what I have so far, which so far is only successful in getting the post_thumbnail:

    <!-- featured slides for the projects -->
    <ul id="featured_slides" class="rslides">
    <?php
    
    		 $related_project_posts = array(
    		 'posts_per_page' => -1,
    		 'post_type' => 'post',
    		 'nopaging' => true,
    		 'suppress_filters' => false, // this argument is required for CPT-onomies	
    
    			'tax_query' => array(
    			 	array(
    		 	'taxonomy'=>'projects',
    			'terms'    => get_the_ID(),
    			'field' => 'slug'
    			)),
    		 );
    
    //		print_r($related_project_posts);
    $postslist = get_posts( $related_project_posts );
    foreach ($postslist as $post) :  setup_postdata($post); ?> 
    
    <li><a href="<?php the_permalink();?>"><?php the_post_thumbnail( 'grid_16_landscape' ); ?></a></li>
    <?php endforeach; ?>
    </ul><!-- featured_slides grid_16 //-->

Topic Closed

This topic has been closed to new replies.

About this Topic