I need to add featured image somewhere near title so I can easier sort them, currently the plugin use this code to show the title only, tried with the_post_thumbnail and nothing is showing up. Thank you.

            echo '<li id="'.$post->ID.'">';
            echo '<span class="title">'.$post->post_title.'</span>';
            echo '</li>';
up vote 3 down vote accepted

Since this is a plugin, it's probably going to get axed, but generally speaking in WordPress if you want to get a posts featured image and you have access to the post ID (which I'm assuming you do), you can always do this:

$thumb_url = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );

So without looking at the plugin, it looks like you might be able to do something like this:

$thumb_url = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
echo '<li id="' . $post->ID . '">';
echo '<img src="' . $thumb_url . '" alt="" />';
echo '<span class="title">' . $post->post_title . '</span>';
echo '</li>';

Set your styles on the image accordingly (height/width/float/margins/etc.)

  • GENIUS!!! Is working! How can I send you a beer at least? – Robert Ramsey Nov 18 '14 at 0:22
  • An accept/upvote will suffice. Glad it worked. Also, if you're not already aware... if you're modifying the plugin source, updating the plugin will wipe this out. – BODA82 Nov 18 '14 at 0:24

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.