Default thumb – how to set it

While there’s no such functionality built into core, there’s a Track Ticket I proposed 2 years ago. You can simply rip of the functionality from the suggested wp_default_img() function. I’ll greatly appreciate any support in comments on that ticket, as this would be highly needed for every theme developer. Thanks in advance. MU-Plugin The following … Read more

Use the_post_thumbnail as background image in LESS CSS [closed]

There’s nothing wrong with an inline style in this case – just set all your other rules in your LESS (like background position, repeat, size), and then in your template: <div class=”something”<?php if ( $id = get_post_thumbnail_id() ) { if ( $src = wp_get_attachment_url( $id ) ) printf( ‘ style=”background-image: url(%s);”‘, $src ); } ?>>

Getting featured image of particular size.

Please refer to the WP-Admin » Settings » Media. There you will find all the image sizes a theme creates. Basically the WordPress by default creates three sizes unless the Original: Large size (Default: 1024 x 1024) Medium size (Default: 300 x 300) Thumbnail size (Default: 150 x 150) From the admin panel you can … Read more

Show Featured Image in else statement

The featured image-related functions do not offer any way to define a default/fallback image. So, you’ll have to define one yourself, e.g. <?php $featured_image = ( ” != get_the_post_thumbnail() ? get_the_post_thumbnail() : get_template_directory_uri() . ‘/images/img_not_available.png’ ); ?> <a href=”https://wordpress.stackexchange.com/questions/118789/<?php the_permalink(); ?>”><?php echo $featured_image; ?></a> Edit Three changes: More explicit conditional. get_the_post_thumbnail() returns an empty string … Read more