WordPress: get_post_thumbnail_id() returns -1

enter image description here

I have this piece of code below that checks if the PAGE has featured image. If it does, echo the URL of the image. if no featured image, display a default image

<div style="background-image: url(<? if ( has_post_thumbnail() ) :  
the_post_thumbnail_url(); else : ?>   http://www.7senarai.com/our-stories.jpg) 
<? endif; ?>" 

I’m not too sure what happened but when I publish new pages now with no featured image, it will look like as if I have a featured image selected but the image is broken. It looks something like below

When I check get_post_thumbnail_id() on these problematic pages, it displays -1

Read more here: WordPress: get_post_thumbnail_id() returns -1

Leave a Reply

Your email address will not be published. Required fields are marked *