WordPress.org

Ready to get started?Download WordPress

Forums

Post image not shown in feed since 3.5 (8 posts)

  1. rancor2k
    Member
    Posted 1 year ago #

    Hey guys

    I just updated WP to 3.5 and noticed, that my script for adding the post image to the rss feed doesn't work anymore. There's no error, just no Picture in the feed. Here is my code, which worked fine until now:

    function my_feed_thumbnail($content) {
    if (is_feed() && has_post_thumbnail()) {
    return the_post_thumbnail( 'single-post-thumbnail' ) . $content;
    }
    return $content;
    }
    add_filter('the_content', 'my_feed_thumbnail');

    Were there changes to the API?

  2. williamespindola
    Member
    Posted 1 year ago #

    This problem is related to insert image in post content. Doesn't work anymore.

  3. Since you're using the return of the function, you should really do get_the_post_thumbnail() -- not the_post_thumbnail() -- the latter just echoes the image to the screen, while the former is meant to give you the image tag in a string.

  4. rancor2k
    Member
    Posted 1 year ago #

    any idea on how to fix this?

  5. Also -- get_the_post_thumbnail would require the first argument passed to it to be either the post_id (gettable via get_the_ID()) or null -- the second arg is the image size. Make sure to bump it back.

  6. williamespindola
    Member
    Posted 1 year ago #

    My problem is not get the picture in post list or open post, but insert image in post content.

    The picture uploaded, but not insert in post content.

    Sorry my english is not very good. :)

  7. rancor2k
    Member
    Posted 1 year ago #

    That did the trick, thanks a lot! Here's my updated code, if anyone is interested:

    function my_feed_thumbnail($content) {
        if (is_feed() && has_post_thumbnail()) {
            return get_the_post_thumbnail( get_the_ID(), 'medium' ) . $content;
        }
        return $content;
    }
    add_filter('the_content', 'my_feed_thumbnail');
  8. williamespindola
    Member
    Posted 1 year ago #

    My problem is compatibility with plugin http://wordpress.org/extend/plugins/custom-field-template/

    witchcraft!

Topic Closed

This topic has been closed to new replies.

About this Topic