Add second background-image on hover

Use a single element, with a pseudo element (:before) for the featured image, and appropriate hover styling to set its opacity and reveal a blend with the underlying second image. I threw in a gradual image transition just to make it look a little nicer. html: <div class=”my-image-holder”> text and other contents we don’t want … Read more

add_theme_support post-thumbnails not working

Have a look at this documentation. This feature must be called before the init hook is fired. That means it needs to be placed directly into functions.php or within a function attached to the after_setup_theme hook. For custom post types, you can also add post thumbnails using the register_post_type() function as well. TRY this add_theme_support( … Read more

Using featured image of blog archive page

You need to grab the ID of the page you’ve set as your Posts page in Settings > Reading in order to access its properties. To do that, check for the page_for_posts option, which returns the ID: $page_for_posts = get_option( ‘page_for_posts’ ); if ($page_for_posts && has_post_thumbnail($page_for_posts) { $thumb_id = get_post_thumbnail_id( $page_for_posts); $url = wp_get_attachment_url( $thumb_id … Read more

All Images not calling alt text

You’re not outputting any attributes besides the src and class. Try using the_post_thumbnail() instead. <?php the_post_thumbnail( ‘post-thumbnail’, array( ‘class’ => ‘img-responsive’ ) ); ?> This will include all attributes and supports responsive image markup by default.

How to set featured image from external url programmatically

You can use the post_thumbnail_html filter to set the post thumbnail programmatically to an external URL. Then you wold set the image URL in a Custom Field on the post writing screen metabox (in this example with a meta key of thumbnail_url): add_filter(‘post_thumbnail_html’, ‘custom_thumbnail_tag_filter’, 10, 3); function custom_thumbnail_tag_filter($html, $postid, $thumbnailid) { if (!$thumbnailid) { $src … Read more

get_the_post_thumbnail() produces different HTML on same arguments

So I found the issue. The twentyseventeen theme has a built-in function in functions.php that does this: Add custom image sizes attribute to enhance responsive image functionality for post thumbnails function twentyseventeen_post_thumbnail_sizes_attr( $attr, $attachment, $size ) it has an if (is_archive()) condition in there. I had to override the function with my own custom function … Read more