Support » Plugins » [Plugin: Multiple Post Thumbnails] Use outside the loop?

  • I need to be able to display secondary images outside the loop. More specifically, I need to be able to get the image URL(s) from outside the loop. Is that possible? the_post_thumbnail() only works inside the loop. I tried to use get_the_post_thumbnail() (it accepts a post ID as an argument so it can be used outside the loop) but the plugin doesn’t work with get_the_post_thumbnail(). Any ideas?

Viewing 1 replies (of 1 total)
  • Answering my own question, I went into the database and noticed that the featured images are just post attachments. So something along these lines may be the right place to start?

    <?php
    	$args = array(
    		'post_type' => 'attachment',
    		'numberposts' => -1,
    		'post_status' => null,
    		'post_parent' => $post->ID,
    		'orderby' => 'menu_order',
    		'order' => 'ASC',
    		'post_status' => NULL
    	);
    	$attachs = get_posts($args);
    	if (!empty($attachs)) {
    		foreach( $attachs as $att ) {
    			echo wp_get_attachment_image($att->ID,'post-thumbnail');
    		}
    	}
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Multiple Post Thumbnails] Use outside the loop?’ is closed to new replies.