How can I display my featured image correctly inside my single posts?

As mentioned by Rahil Wazir, take that code snippet <?php the_post_thumbnail(); ?> away from single.php. Put following in your functions.php (at the bottom) add_filter(‘the_content’, ‘put_thumbnail_in_posting’); function put_thumbnail_in_posting($content) { global $post; if ( has_post_thumbnail() && ( $post->post_type == ‘post’ ) ) { the_post_thumbnail( ”, array( ‘style’ => ‘float:left;margin:15px;’ ) ); } return $content; } Change the … Read more

Featured image size in ADMIN panel?

You can filter ‘admin_post_thumbnail_html’ and replace the img element with a new one in the size you need. Everything else will get messy and might lead to side effects. Filtering image_downsize while watching for a size of 266×266 might affect images that are not meant to be shown in the metabox. Changing the size for … Read more

adding an id to the_post_thumbnail

Use get_the_post_thumbnail() instead. It allows you to pass in an array of attributes for the image tag that gets returned. For example: $attr = array( ‘id’ => ‘YOUR-UNIQUE-ID’, ); echo get_the_post_thumbnail( $id, ‘thumbnail’, $attr ); EDIT: I’m dumb. the_post_thumbnail() also lets you do that. Try passing the same args array I outlined as the second … Read more

Skip posts without a thumbnail in loop

You can try to add ‘meta_key’ => ‘_thumbnail_id’, to your input arguments: $args = array( ‘numberposts’ => 5, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘meta_key’ => ‘_thumbnail_id’, ); to query only posts with thumbnails (i.e. featured images). ps: instead of this structure: if ( !has_post_thumbnail() ) { continue; } … Read more

Multiple featured image thumbnails for post types (Multiple Post Thumbnails plugin)

Dude, you’re doing this the hard way. You can do what you want totally with a single ‘featured post thumbnail’. Read the documentation about thumbnail sizes in themes. You can inject custom thumbnail sizes in your themes funcitons.php and then give them as a parameter to the (get_)the_post_thumbnail() function. Please just read the documentation at … Read more