try using an empty condition
<?php
$bgimage= get_post_meta( $post->ID, 'settings_image', true );
if (!empty($bgimage)) {
$imgURL = wp_get_attachment_url( $bgimage );
?>background: url('<?php echo $img ?>')<?php } ?>
That should work as it checks to see if there is anything stored in the meta and will not print the background: url('')
if there is no data.
Related Posts:
- How do I add settings to the Background Options Page?
- esc_url not working within add_settings_field callback
- Settings API enable default settings on theme install?
- get_option() returning empty
- Where to hook settings api init
- How would you accomplish the following advanced settings page?
- Consequences if using PHP include TEMPLATEPATH?
- not getting API setting saved confirmation message after update on option page
- Tabbed theme options query about add_settings_section callback function
- How to register dynamic settings in WordPress Customizer?
- Warning: This page allows direct access to your site settings. You can break things here. Please be cautious!
- WordPress theme options checkbox default checked state
- WordPress theme settings not saving
- Create settings field on button click
- Data not saved WordPress Custom Admin Page
- Let users to add any number of input fields in the theme option page
- Making update notification functionality for my themes
- Should `get_template_directory_uri()` be escaped?
- Best practice for including plugins as part of a theme?
- How to disable 3.1 “Admin Bar” via script for the admin user?
- Where do I find the functions triggered within a hook?
- Is it possible to display the admin bar while in the Theme Customizer?
- How to Change CSS Variable value in Theme Customizer Live Preview
- Pagination & get_pages?
- index.php is not loaded for single posts
- Easy WordPress theme creation tutorial? [closed]
- How do I add a post to a menu
- Demo Import changes terms ids
- how to change WordPress menu markup/classes
- Best practices: Custom theme sidebar menu – hardcode or widget?
- how to implement wp_is_mobile on themes?
- Where is definied the theme location for the main menu in a WordPress template?
- How to get the URI to a theme without the domain. Example: /wp-content/themes/my-theme
- How to disable automatic colors in the Twenty Twenty theme?
- Check if user has enrolled in Sensei LMS Course on Lesson Page
- How to handle custom form submission?
- menu behavior is not as expected
- My custom theme does not load the translations
- Child theme style.css versioning
- Disable front-page.php template
- Gutenberg – editor-font-sizes in functions not working
- Same ACF on two different pages
- A mystery 300px image size
- How to use get_template_part instead of include_once?
- How to remove comment link title attribute?
- Custom Field returning Numerical Value for Image rather than URL
- which is the best way to customize nav-menu-template.php?
- Should we use ob_start() in WordPress short code
- wp-cli: For development, how can I activate a theme that is on the local disk but not zipped?
- Default string not appearing want to translate
- How to make a local cache of mshots images
- Why is the Page Template dropdown menu using the wrong file name?
- Using a page as home, how do I prevent nav from setting both home and page links active?
- 2 localizations inside a WordPress theme
- How can I ping update-core.php with a script?
- Custom theme updater – random string in new theme name
- Child Theme’s style.css not loading in mobile browser
- How to Find the Page the Front Page is Using?
- My jQuery is enqueued properly. So why isn’t it working?
- Database Tables in WordPress Theme
- 3 Level Deep Navigation Menu Not Showing All Levels
- Broken theme, template is missing
- WordPress page/blog incorporated into static website
- wp_enqueue_script not working?
- Random white space before doctype
- Theme Development -> Specific Homepage
- Premium theme licensing of php called through AJAX
- is_single() works in plugin, not in theme?
- Do I need to create a child theme for JointsWP
- Issue on Accessing To Ajax Enqeued File to Pass to URL for Ajax Call
- pass wordpress template directory into ajax url call
- Javascript development in Custom Themes
- Custom jquery not code not working in wordpress
- License of the used Bootstrap Theme is not GPL compatible
- Style first 3 posts differently with WP_Query [duplicate]
- Post archives link yields a 404 Not Found
- is_front_page use in sidebar.php
- matisse theme show excerpts not whole content
- My custom taxonomies are not showing up in the admin menus
- Let user to upload multiple time
- get main URL from subdirectory with php
- How to add custom theme in hosting server?
- Infinite loop when nesting have_posts()
- WordPress Custom Theme : Theme Builder vs ACF vs Gutenberg
- Is_single not working properly in genesis
- Debugging slow WordPress Theme Customizer (Any option similar to Query Monitor)?
- register_theme_directory() sees custom themes directory, but blank frontend
- After WP 4.6.1 Update , Blog page started giving 500 error
- How to show children pages as array
- How do I keep images in posts below a certain size without editing the post?
- Theme options not displaying correctly after theme update
- Multiple Content Shortcodes
- Is it possible to customize the layout of Gallery Shortcode?
- How can i use archive.php for indexing wordpress default posts?
- Add the ability of changing background color of a theme [closed]
- How to use esc_attr__() function properly to translate a variable that contains string?
- What to do when child theme is out of date with parent theme
- Query for tag given slug
- Image Size wrong during upload
- How can I add a single image from a gallery into the page header?