Deprecated: Return type of HM\BackUpWordPress\CleanUpIterator::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/charlott/ourfragileplanet.com/site/wp-content/plugins/backupwordpress/classes/class-path.php on line 455
Loops of featured images by category - Our Fragile Planet

Loops of featured images by category

I set up a loop to call the featured image from 5 posts from a certain category in wordpress.

Without:

$do_not_duplicate = $post->ID; 

I got duplication. So this is the code for the loop.

// The Query
$the_query = new WP_Query( array ('category__in' => '5','posts_per_page' => '5','orderby' => 'rand') );
$do_not_duplicate = $post->ID;
// The Loop
while ( $the_query->have_posts() ) :
	$the_query->the_post();
	echo '<li>'; echo '<a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';
      echo get_the_post_thumbnail($thumbnail->ID, 'medium');
      echo '</a>'; echo '</li>';
endwhile;
Scroll to Top