I want to get pages featured image.
I create a blog page and upload a featured image and i use this code for showing the featured image.
$cb_banner_back = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), $cb_image_size);
<img src="<?php echo $cb_image_size; ?>">
It works perfectly, but now i write wordPress query to call all posts now it shows me recently posted post featured image it does not show me page featured image.
I first use the_post_thumbnail('image_size');
then i use above code.
Is there any solution or hook for wordpress
try this code this is working for me.
<?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
echo '<img src="'. $image[0] .'" alt="'. get_the_title() .'" />';
<?php endif; ?>
check this and let me know if not work.