WordPress.org

Ready to get started?Download WordPress

Forums

Getting Post Image (2 posts)

  1. KvnKrft
    Member
    Posted 1 year ago #

    This is a re-post, because I believe I should have posted this in here to begin with.

    Good evening all, another problem that is going to keep me up.

    I am building a new RSS feed specifically for newsletters via Mail Chimp. Everything is working, it is displaying nicely, other than the Post Image. I can't get it to / echo. Why? Why?

    The current setup is WordPress 3.5 running Thesis 1.8.5.

    <?php foreach ($posts as $post) { ?>
    
    	  <item>
    		<title><?php echo get_the_title($post->ID); ?></title>
    		<link><?php echo get_permalink($post->ID); ?></link>
    		<description><?php echo '<![CDATA['.only_get_up_to_more_tag($post->post_content, 500).'<p>Keep on reading: <a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a></p>'.']]>';  ?></description>
    		<pubDate><?php rss_date( strtotime($post->post_date_gmt) ); ?></pubDate>
    		<guid><?php echo get_permalink($post->ID); ?></guid>
    		<media:content url="<?php echo wp_get_attachment_url(get_post_thumbnail_id($post->ID)); ?>" medium="image">
    			<media:title type="html"><?php echo get_the_title($post->ID); ?></media:title>
    		</media:content>
    	  </item>
    
    <?php } ?>

    It is a bit strange before everything else is working, but I believe it may have something to do with Thesis.

    I have add_theme_support( 'post-thumbnails' ); added to the custom_functions.php file. Which I believe is a must, but I am not even sure if the page pulls in the custom_functions.php file, as I have the code in a php file and pull it in via template/page config.

    I did try the code straight in the page though, and it also doesn't work.

    ANY help would really be appreciated.

    Kevin

  2. bcworkz
    Member
    Posted 1 year ago #

    I believe the theme support bit is what places the meta box in the posts edit screen which allows you to pick a featured image. If you do not pick a featured image, none of the post_thumbnail type functions will work. You can't simply insert a thumbnail sized image. It must be featured. I'll assume you did that.

    FWIW, your code works fine in my essentially themeless test page. Of course, I have a theme to create posts and attach featured images, and it gets loaded in the background, it just has no direct influence on the page output.

    You'll possibly need to do some careful debugging to find out what's messing with getting the image url, but it's not the code you posted. And it's unlikely the theme support bit if you were able to pick a featured image.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.