Just set up a condition to check that thumb_id isn’t empty. If it is, use your alternative image. Pretty simple stuff.
<?php
$thumb_id = get_post_thumbnail_id();
if ( $thumb_id ) {
$thumb_url = wp_get_attachment_image_src($thumb_id,'thumbnail', false);
$thumb_url = $thumb_url[0];
} else {
$thumb_url="http://www.website.com/img/default.jpg";
}
?>
<div class="content" style="background-image:url(<?php echo $thumb_url; ?>);">
Related Posts:
- retrieve thumbnail from post ID of best selling product in category
- WordPress remove EXIF Data from specific Thumb
- How to use SRCSET with get_the_post_thumbnail()?
- Additional image sizes are not being generated
- How to make thumbnail image fit into a div where image dimentions are completely different?
- How to restrict wp generate attachment metadata() to certain intermediate image sizes
- hover image appears below placeholder instead of overlayed
- combine Code 1 with Code 2
- Trying to remove post thumbnail with plugin
- How to use thumbnail size of image if I’m only using src to get image
- Thumbnails appear to be zoomed
- ‘Post-thumbnails’ feature does not seem to register
- get taxonomy thumbnail and use it as a variable in code
- Custom Post type slider with thumbnail navigation
- Else/If Statement to Display Photo Descriptions
- How to Make Thumbnail of Post Stay Animated
- Showing wordpress latest post thumbnails in slider with auto increment
- How to correctly add the featured immage (thumbnails) support in a WP theme? Why I can’t add a featured immage?
- PHP-Code inside Href-Tag
- How can i give a download link to the thumbnail or featured image
- why css file not link?how to create permalink?
- How to fix “Headers already sent” error in PHP
- What are PHP extensions and libraries WP needs and/or uses?
- How to get WordPress Time Zone setting?
- how to get page id of a page using page slug
- How to stop form resubmission on page refresh
- the_author_meta() vs get_the_author_meta()
- Displaying a WooCommerce product via PHP
- Enqueue Javascript Correctly for 3.5
- How to get the ID of an item in an audio playlist?
- Does wordpress allow me to add a php file to the root directory to execute custom scripts?
- Add footer.php to WordPress child theme
- Passing a shortcode attribute to a sub-function
- how to display active, upcoming and past event with featured listing with pagination
- JS completely stopped loading but Files are found
- Import 10,000 Users into WordPress WITH a specific ID for each user
- Restrict WordPress File Type Uploads by User Type
- Click loads template via ajax
- Why isn’t the canonical link element used for all pages?
- How Can I Call Up The Author’s Name on a Post
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Automatically remove a canceled order in Woocommerce
- How to pass arguments to add_action() or retrieve return value of called function?
- Get WordPress Category ID from a URL string
- How to remove the cufon script from Dzonia Lite theme [closed]
- Seach custom post type posts only by meta fields?
- Ajax request returns ‘Array’. How to output the actual results?
- Display a message if posts dosen’t exist on loop
- Get post id within comments loop
- Woocommerce change prices for a certain country [closed]
- WordPress Environment: Dynamic Page using shortcode – how to change the page name for sharing
- Should i use the wordpress Options table or to create database table..?
- Where are the src and srcset sizes coming from?
- wp_remote_post empty $_POST
- How can I spin up a new website for a registered user automatically?
- What is the alternative code to if (isset ($_POST) && !empty ($_POST) to avoid warnings?
- How to show every second user different types of banners?
- Woocommerce – get_items() returns empty array
- Need help with pagination
- get_comments_number() returns 0
- Adding Additional Variables on Menus Page
- Querying for specific tags
- Why the dynamic_sidebar() call is putted into an ul tag?
- Compare current post Category in select menu
- how to changes mobile menu toggle breakpoint in WordPress
- Get page permalink in contact form
- Get quantity of children in all parents and add quanity to all UL class names
- How to display already created menus via php?
- How to store checkbox data for individual users?
- Grabbing Image name From Product Image Gallery
- Allow two posts (from different categories) to have the same slug
- Test the existence of a page/article by its URL, taking in consideration the URL rewriting by filters
- Cant get blog name with get_option
- how to add new PHP page in WordPress plugin
- How can I get my WordPress plugin to receive data and relay it in an ajax/php request to a remote server that requires authentication?
- Time out opening second page in same browser with long running page load
- How to display category and tag descriptions in a post
- Can’t display anything through homepage text editor
- Issue with json decode in WordPress – value is not returning consistently
- Extra editor on top of default in Custom Post Type
- Adding if statement
- Pagination 404 error(I have refreshed the permalinks and tried several previous options)
- How Can I Display the Last Modified Date for User Profiles on WordPress?
- Input field duplicates on form submit by jQuery
- How do I fix this error
- Ajax wordpress function showing source code in alert and not value of input field?
- Get Posts by Custom Taxonomy on Custom Post
- Get a list of tags present in a paged front page
- Adding a number to a date
- the_post_thumbnail(); only works with fullsize images
- I want my wordpress loop to only display posts of the standard format
- Target all images that are not the first attachment
- Search through documents folder
- Listing current pages subp page in list items in the sidebar
- Add CSS class to PHP Statement
- Passing javascript variable to php file
- Getting the title of the parent page and displaying it only for certain parent pages
- PHP – Converting elements to actual values
- Importing data from excel sheet on webpage rather than from within phpMyAdmin
- Dynamic PHP content in Block Theme template file