Please notice, has_post_thumbnail()
does not only check to see if the post has a featured image, but also checks if there is an image in the post itself. There is a quote from WordPress Code Reference:
It’s worth noting that
has_post_thumbnail()
does not just check for
the Featured Image as the Codex User Contributed Note suggests. If a
post contains no defined featured image but it does contain an image
in the content this function will still return TRUE.
I suggest you use if (get_the_post_thumbnail() != '')
instead of if (has_post_thumbnail())
.
Related Posts:
- How can I make add_image_size() crop from the top?
- What plugin can I use to create a list / slideshow of featured images?
- Prevent publishing the post before setting a featured image?
- Modify featured image URL at runtime
- Add post thumbnail from external image with plugin
- Thumbnail with different sizes
- Meteor Slides as header only for homepage and Use featured image of each page as header for respective pages
- Set WordPress Featured Image For All Post Slugs Matching Image File Name in Specified Directory
- AJAX image upload with a upload progress bar using media_handle_upload
- Converting Attachment to Images?
- ReOrder Post Within Categories plugin with featured image
- Any Short code Availble for Get Post List With Thumbnail Plugin?
- Set featured image using javascript in post editor
- Add padding while generating thumbnail
- How to export all content with feature images?
- Redirect to another page using contact form 7? [closed]
- Is there a best practice remediation for PhpStorm’s warning that void function the_post_thumbnail is used?
- Plugin to hide image in excerpt
- Cropping images from top center using Jetpack Photon
- Add “Featured Image” box in my plugin post page
- Couple of beginner’s questions [closed]
- Scrape a webpage for image and add it to post
- Adding featured image to posts created by a plugin
- Regenerate Thumbnails Plugin successfully updated my thumbnails but image src won’t change to new image size?
- Add_image_size not generating correct size
- Multiple Post Thumbnails Plugin – Need help with code
- How to hide featured images of all posts falling under the same category in wordpress?
- Revision featured image
- Allow webp use on website but disallow webp as featured image during post creation
- Upload Image with a file URL and show dynamically on Frontend
- insert og image link in wordpress post
- How to Add call button on a featured image in a wpsite? check the slap king image, there are two buttons on the featured image
- Display Multiple Photos as Featured Image when mouse moves on to it post
- Use AJAX to fetch Current Post Thumbnail for WordPress when Uploaded throughMedia Uploader Frontend
- automatically set random featured image by category in wordpress on post
- Import 2000 posts from one website to another
- Hide Featured Image in AMP
- WordPress create thumbnails on demand
- Automatic set a featured image from the first image’s url (or tag) in the article
- Does WordPress have a way of changing the ‘Natural’ size of uploaded images?
- Update (a function) post’s featured image as soon as $image_url changes
- Adding featured image to post display widget
- Do something with thumbnail image on post publish
- How to force regenerate thumbnails in WordPress posts?
- How to add featured image on front end form?
- Lazy Load sometimes don’t work
- Determine if get_the_image has image on Get the image Plugin
- Advanced Custom Field User Help URL
- Retrieve post thumbnails
- featured image problem with custom post type
- Looking for a related post plugin which slides-in like the one at inc.com does [closed]
- when i use wp automatic plugin post shows broken images
- Display Video as Post Thumbnail
- Get URL for featured image for posts? [closed]
- Multiple Post Thumbnails Not Returning URL for Background Image
- Should all plugins be encapsulated in a Class?
- In what order does WordPress load plugin files?
- Add a subitem to Woocommerce section
- Using rewrite rule to access a view of a plugin from home page
- How to Get Admin Settings for a widget when using the_widget() with custom widget
- Upload files programmatically to users
- Shortcode in AJAX popup
- Why none of the plugins that have ajax doesn’t work in my website?
- wordpress reusable content blocks
- Is there a filter for get_post_custom()?
- Problem with wordpress version 3.8
- How to make a customize role and view a specific plugins base on that role?
- Removing an action from wp_footer called in a class that’s inside a bigger class
- WordPress Widget – Saving multidimensional arrays into $instance
- Advanced Custom Fields – Get value in other plugin file [closed]
- How to get menu location in wp_update_nav_menu hook
- WordPress Console Application (ability to excecute a custom function via crontab only)
- How to add table class for tables of TinyMCE advanced wordpress plugin? [closed]
- Huge number of 404 pages getting spawned
- Licensing options for WordPress Plugins
- Updating WordPress across multiple versions
- Why does my jQuery plugin show up as text in WordPress?
- I am Unable to access WP admin
- Embed PDF into wordpress
- Replace woocommerce | (pipe) separator in product variation to , or another character?
- Why are my constants not available outside my class?
- WordPress does not allow me to upload a .xml file
- WordPress FLIR (Facelift Image Replacement) plugin clipping off end of text
- WP Subtitle Plugin Problem
- Add a new category for posts
- How to use a shortcode or an application to dynamically embed content from one WordPress site to another?
- How to get brand children with woocommerce brands
- Create Woocommerce account password post-checkout on thank you page
- dokan edit functionality
- How do I insert a shape onto an image and then play an audio file upon mouse hover or mouse click on that shape in WordPress
- How to migrate Powerbuilder page data to another site?
- Passing ajax variable to more than one wordpress plugin function
- Changing the body of mail sent to new user registration
- WordPress hook source
- using jquery serialize in ajax operation for plugin
- is there a way I can add or remove some plugin options?
- How to add homepage Widget?
- Embedding BitBucket Code in Posting
- WordPress show different custom post type
- WordPress error Fatal error: Uncaught TypeError: Argument 3 passed to Automattic :get_setting_for_feature() [closed]