Layer post title on top of image WordPress featured thumbnail image

the_post_thumbnail() does not return the path of your image. Instead, it returns the complete HTML markup for that image. You can use this instead: $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ) ); echo $image[0]; If you want a specific size you can pass an additional parameter: $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘full’ ); echo $image[0]; … Read more

how to use the new image size

By default WordPress has three four different image sizes: full, large, medium, thumbnail. If you don’t need more than three images size, you can set the with and height of the default image sizes. For example: add_action( ‘after_setup_theme’, ‘theme_setup’ ); function theme_setup() { // Be sure your theme supports post-thumbnails add_theme_support( ‘post-thumbnails’ ); //set thumbnail … Read more

Using global $post; to get featured image for custom post via WP_Query

$port_query->the_post(); should set the $post global. That isn’t the problem. The problem is that the you are trying to use $post before your secondary Loop runs (99% sure). You’ve hooked the bkg_featured_image() function to wp_head. wp_head runs in the header of the document, which, unless you are careful, will run before the other template code. … Read more

Can’t show custom post thumbnail sizes as background images

Use this. you will need to call thumbnail sizes. $small_regular = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID), ‘small_regular’ ); $big_regular = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID), ‘big_regular’ ); echo “<style type=”text/css”>”; echo “.entry-featured-image { background-image: url(‘” . $big_regular[0] . “‘); }”; echo “@media screen and (max-width:48em) { .entry-featured-image { background-image: url(‘” . $small_regular[0] . “‘); } }”; echo “</style>”;