WordPress.org

Ready to get started?Download WordPress

Forums

get image from post (3 posts)

  1. DDT
    Member
    Posted 5 years ago #

    How do you get a corresponding image from a post???

    i am creating a custom template index which loops thru the posts and i like to show an image if a post has one and otherwise show a image_placeholder

    if($imgSRC != ''){
    here the first image of post??
    } else {
    $imgSRC = 'image_placeholder.gif';
    }
  2. there are some articles on the web on how to get images from posts that might give you some ideas:
    for instance:
    http://www.snilesh.com/resources/wordpress/extract-images-from-wordpress-post/

    http://bavotasan.com/tutorials/retrieve-the-first-image-from-a-wordpress-post/

    http://rider.sofarider.com/blog/wordpress-tips/how-to-add-an-image-teaser-next-to-post-title/

    at least it might give you some keywords to expand the search.

  3. nathan12343
    Member
    Posted 5 years ago #

    Thanks for posting these links. I tried the first two and both were easy to follow and did the job perfectly!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags