You can test if the $thumb
has any contents and then apply a class to the featured image block that you can use to hide the container.
<?php
$thumb = wp_get_attachment_image_src(
get_post_thumbnail_id($post->ID),
'full'
);
?>
<div id="post" class="featured-image <?php echo empty($thumb) ? 'no-featured-image-class' : ''; ?>" style="background-image: url('<?php echo $thumb['0']; ?>')">
Related Posts:
- WordPress loop specific thumbnail size
- How to scale image with equal width and height without distortion?
- How to stop featured image thumbnail [set as background image] on blog index page just repeating same image across all posts
- height should be set to auto to avoid pixelation in the post thumbnail function
- featured post as div background
- Adding first / last CSS classes to menus
- What’s the best way to use the Featured Image for responsive web design?
- WordPress Admin Bar pushed Sticky Footer off the bottom of the page
- Adding Featured Image to Post programatically
- “wp_enqueue_style();” don’t load new edited style
- How to add a featured image to a existing post via php?
- functions.php not adding css to website?
- if file_exists not working with wp_enqueue_style
- Using PHP to toggle stylesheet and header image, set in cookie
- Archive dropdown styling not applied
- Different background-image by category
- Add a Different CSS Class Into The Body Tag of Different WP Pages
- How can I show the post thumbnail from the most recent of a certain post type, in widget?
- How can I add pagination and how can I change thumbnail size?
- How Display Posts on category
- Slider loading issue
- Parent theme CSS overriding child CSS rules
- How to style options page in dashboard?
- Theme Options Page – User Updates Logo
- Dynamic Stylesheet loads but doesn’t finish
- How to add date to navigation bar
- Is it possible to use Data URI image to set a post thumbnail?
- Incorrect MIME type for assets with Valet
- Display custom post type title as text if post thumbnail is not available
- Customize position of social icons in upme plugin [closed]
- Css loads very slow [closed]
- How create a Shortcode with hover and complex options
- WordPress Multiple Navigation bars
- Which is the correct way to conditionally enqueue a CSS file?
- Use PHP in stylesheet to specify a background image based on Category ID
- ‘Post-thumbnails’ feature does not seem to register
- WordPress wp_add_inline_style unable to give hex colors?
- How to make container class in PHP
- How to create table in wordpress without plugin? [closed]
- Add class to DIV depending on page loaded
- Liking a facebook page from wordpress website?
- trouble with page_id & highlighting current page
- wordpress admin plugin menu custom css
- Automatically add images to a menu
- Where can I find the inline-css of my theme header?
- Website completely messes up when logging out
- Issue Enqueueing WordPress style.css
- Error display post thumbnails for previous and next post
- Fallback image URL if no featured image exists via a shortcode function
- How to add new CSS file to new PHP file
- Applying CSS on PHP variable [closed]
- Get the alt text of the image in a array
- Timber right sidebar in WordPress theme
- How to find which .mo file is responsible for displaying a particular localized string?
- How to Remove Theme Style CSS inside Custom Plugin?
- Add other class content with reference class value
- Add Featured Image to Existing Post
- Adding Custom css file in the wp-uploads directory with custom php functions
- Replace background image with post thumbnail in shortcode
- Resize post thumbnail
- How to hide a div section when user is logged in, in single product woocommerce
- How do I integrate vanilla Javascript to a wordpress website?
- Cannot dequeue Elementor Font Awesome css
- How to find and delete a menu item in php?
- WordPress Slider is not working
- How to display post meta bellow every posts
- Add my footer menu to the header
- Add Shortcode to ::before class
- Fix hover images blink
- Blog Image and Title in Right Sidebar
- Thumbnail wouldn’t scale to size properly
- Displaying POST content with HTML tags and all
- How to add Open/Close Toggle button into Twenty Fifteen theme for hiding left sidebar?
- Position a repeated article blocks
- Custom Thumbnails [closed]
- Custom Theme, Editor won’t wrap text (i.e. change width)
- Can’t put a hyperlink on Featured Post’s Image
- How to correctly add the featured immage (thumbnails) support in a WP theme? Why I can’t add a featured immage?
- Revision History for Entire WordPress Site
- wp add inline style in loop
- Post Thumbnail on Single (if elseif else)
- Display pages from specific page template
- the_post_thumbnail unless video id is added
- How do I use CSS or PHP to customize WordPress Form Manager Plugin Table?
- Sidebar doesnt get updated?
- How to NOT override inline css rules
- Add CSS class to PHP Statement
- How to add margin underneath woocommerce total price amount -> productpages
- Load files content [closed]
- Load slideshow.css file only if Slideshow is checked / on
- add if statement to the featured image
- Predefine Magazine Style Layouts
- It’s not showing full content for posts pages in wordpress “[…]” while customing some changes in the style.css file [closed]
- Add a “Next Post” & “Previous Post” styled button manually to a post
- Sorting Problem
- Custom HTML/CSS Theme into WordPress – SEO considerations
- Generate and upload screenshot as featured image for user-submitted post
- WooCommerce Checkout Cart [closed]
- why css file not link?how to create permalink?
- Using Featured Image as Hero Background in Word Press