I want to display content from a blog on a corporate page. I am stuck with the thumbnail however–I have assigned a new image size (64x48px) and I have to get its src.
This is the code I’ve got, but it doesn’t work the way I want it to.
<?php
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
?>
<?php
global $post;
$args = array('posts_per_page' => 3, 'category' => 632);
$externalSitePosts = get_posts($args);
foreach($externalSitePosts as $post) : setup_postdata($post);
?>
<?php
//This one gets me the src of the original file (full)
$thumbnail = wp_get_attachment_url(get_post_thumbnail_id($post->ID, 'myResizedThumbnail'));
echo $thumbnail;
//This one displays the properly generated thumbanil image with the size as assigned in functions.php (64x48), I need the src though
$thumbnail1 = the_post_thumbnail('myResizedThumbnail');
echo $thumbnail1;
?>
<?php endforeach; ?>
Thank you! 🙂
You’re looking for wp_get_attachment_image_src();
<?php wp_get_attachment_image_src( $attachment_id, $size, $icon ); ?>
It’s going to return
http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
So you’d do this: