[wp-trac] [WordPress Trac] #25476: Unable to get thumbnails in widget
WordPress Trac
noreply at wordpress.org
Thu Oct 3 10:35:04 UTC 2013
#25476: Unable to get thumbnails in widget
-----------------------------+---------------------------------------
Reporter: benwilcock | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Post Thumbnails | Version:
Severity: normal | Keywords: needs-patch needs-testing
-----------------------------+---------------------------------------
Below is the code I've been using for a short code to display post
thumbnail, I wanted to use this same code to make a slideshow widget.
However it will not return any image url, this is the case for
get_the_post_thumbnail(); too. I have also tried various ways of passing
in the post ID none of witch have worked.
I believe this is a bug as the exact same code works fine in a short code,
and everything else is returned, I will also include the output from this
widget below.
{{{
$img_query = new WP_Query(array('post_type' => 'user_images'));
if($img_query->have_posts()){
$out = "<ul class='user_images'>";
while ($img_query->have_posts()){
$img_query->the_post();
$img_id = get_the_ID();
$img_event = get_post_meta($img_id,'_event_link',true);
$image_url = wp_get_attachment_image_src(
get_post_thumbnail_id(), 'thumbnail');
$out .= "<li>
<a href='".get_permalink($img_event)."'><img
src='".$image_url[0]."' /></a>
<div class='imageCaption'>
<p>".get_the_title()." @
".get_the_title($img_event)."</p>
</div>
</li>";
}
$out .= "</ul>";
}else{
$out .= "No Images";
}
echo $out;
}}}
Output
{{{
<ul class="user_images">
<li>
<a href="http://localhost"><img src=""></a>
<div class="imageCaption">
<p>title @ title</p>
</div>
</li>
</ul>
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/25476>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list