Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#25476 closed defect (bug) (invalid)

Unable to get thumbnails in widget

Reported by: benwilcock's profile benwilcock Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Post Thumbnails Keywords:
Focuses: Cc:

Description

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>

Change History (2)

#1 @benwilcock
11 years ago

  • Keywords needs-patch needs-testing removed
  • Resolution set to invalid
  • Status changed from new to closed

#2 @ocean90
11 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.