Support » Fixing WordPress » Get an image with a given title from post’s gallery

  • Resolved wickethewok

    (@wickethewok)


    On my individual posts’ pages I want to have different images outside of the posts’ content. To do this, I figured I would have admins upload different image files with the title “banner” to each post’s gallery. How can I can retrieve and display this image in single.php?

    Note that I am already using the WordPress post thumbnail feature for an actual thumbnail for each post, otherwise I would use that.

Viewing 1 replies (of 1 total)
  • I think I finally figured it out…

    have_posts();
    the_post();
    $images =& get_children(array('post_mime_type' => 'image', 'post_parent' => get_the_ID()));
    rewind_posts();
    
    $image_url = null;
    foreach($images as $image) {
    	if($image->post_title == 'banner') {
    		$image_url = $image->guid;
    		break;
    	}
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Get an image with a given title from post’s gallery’ is closed to new replies.