WordPress.org

Ready to get started?Download WordPress

Forums

wp_get_attachment_image - Last image returned from post (1 post)

  1. ravichandranjothi
    Member
    Posted 2 years ago #

    Hi Team,

    i am using below code for generate images in feed,

    function show_image_feed($content) {
    
    global $post;
    $args = array(
    'post_type' => 'attachment',
    'numberposts' => 1,
    'post_status' => null,
    'post_parent' => $post->ID
    );
    
    $attachment = get_posts($args);
    
    if ($attachment) {
    
     $content =  wp_get_attachment_image($attachment[0]->ID, 'medium') .'<p>'. $content . '</p>' . '<br />';
    }
    
    return $content;
    
    }
    
    add_filter('the_excerpt_rss', 'show_image_feed'); // for feed excerpts
    add_filter('the_content_feed', 'show_image_feed'); // for full feeds

    I included two images into the post one at the top and another one in bottom. but in the feed the bottom images is displayed first in the content part, i need first (top) image of the post.

    What i need to do?

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 2 years ago by ravichandranjothi
  • This topic is not resolved
  • WordPress version: 3.2.1