[Plugin: Multiple Post Thumbnails] Use outside the loop? (2 posts)

  1. TakeoK
    Posted 4 years ago #

    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?

  2. TakeoK
    Posted 4 years ago #

    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?

    	$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');

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.