Your code:
$bg = (!$bgimage == '') ? 'style="background-image:url'("".$bgimage[url].'")' : '';
There’s a confusion with the quote marks. You’re closing your '
too early, but it’s really hard to see in a construction like this. (Also, the array index needs to be wrapped in quotes, either single or double.)
$bg = (!$bgimage == '') ? 'style="background-image:url("'.$bgimage['url'].'")' : '';
might clear up the PHP error, but I’m not sure it’ll still do what you want it to. There’s still some confusion with quote marks in the CSS; also, is $bgimage
a string or an array?
I’d recommend not using the ternary operator, in this case, to make the code more readable.
$bg = '';
if ( ! empty( $bgimage ) ) {
$bg = 'style="background-image:url(\'' . $bgimage['url'] . '\')";
}
Related Posts:
- How to disable the fatal error (WSOD) protection?
- Could not create directory /wp-content/upgrade/
- Getting the warning: Missing argument 2 for manage_posts_custom_column()?
- What log files does a WordPress installation write to?
- HTTPS leads to Sorry, you are not allowed to access this page
- How to use WP_Error $data argument?
- Is it possible to disable caching of an option when using w3 total cache?
- Showing error “Function create_function() is deprecated”
- error_log over 70GB. How to stop this? [closed]
- Update wordpress fail – There has been a critical error on your website
- Getting headers already sent error from plugin
- “Notice: Undefined index:” error when adding new content?
- Object of class WP_Error could not be converted to string
- New WordPress Error Message – Not seen this before
- Recommend a guide to catching plugin errors, please?
- How to handle core code throwing notice on valid input?
- Getting Warnings & Notices from Fresh WordPress 3.1.2 install
- What do these “Failed to import” errors mean and how do I fix it?
- Trying to get property of non-object in wp-includes/capabilities.php
- How to use add_settings_error in register_setting callback
- Application passwords not working on localhost?
- File available but giving 404 in wordpress
- In big trouble – Allowed memory size of 268435456 bytes exhausted
- PHP Warning : A non-numeric value encountered
- Wordpres debug.log PHP Notice: is_singular was called
- Warning: Declaration of QuietSkin::feedback error
- failed to open stream: No such file or directory
- Getting 403 Access Denied Error Message in new WordPress Post
- update user information
- Error! 401.shtml file not found, what’s the problem?
- Error wordpress “Call to undefined function aq_resize()” [closed]
- Strange glyphs code error
- Sorry, you are not allowed to access this page dashboard
- Custom slider throwing an error
- How to Fix “Are You Sure You Want to Do This”, while uploading my theme?
- Homepage Not Found Error [closed]
- 4.2.2 stuck in an db upgrade loop with “Call to undefined method wpdb::get_col_length()”
- Cannot redeclare maybe_create_table()
- Fatal error: Allowed memory size of 146800640 bytes exhausted (tried to allocate 57 bytes) in public_html/wp-includes/rewrite.php on line 1561
- Display all WP Errors together during form validation
- Updating posts exceeds maximum execution time
- “Cannot modify header information” means I can’t use wp_redirect
- How can I use wordpress functionality outside of WP framework
- Errors in Add Image Popup, Media Library Tab: “in_array() expects parameter 2 to be array, null given in wp-includes/query.php”
- hypanis.ru wordpress vulnerabilty [closed]
- Why do get_category_by_slug() crashes WordPress 4.8
- Child Theme Fatal Error [closed]
- Jetpack could not contact wordpress [closed]
- Overwrote index.php. When I restored it, I got lots of Notice level errors
- 403 forbidden access to my whole site
- Warning: require_once(/home/onetwo/public_html/wp-config.php): [closed]
- Constant WP_CRON_LOCK_TIMEOUT already defined in /htdocs/wp-config.php
- Downgrade from latest nightly build to latest stable version
- styles/default.css in markup, where does it come from? [closed]
- Warning: call_user_func_array() [function.call-user-func-array]
- Parse error: syntax error, unexpected [closed]
- Undefined index error on options array element?
- Failed to import “File name”: Invalid post type jetpack-portfolio
- Getting no Error Log File saved to my local directory, and no debug info displayed in the web browser
- Error call_user_func_array() After Installing Plugin
- Error 500 when installing WordPress
- Unable to edit with Elementor
- Warning: call_user_func_array()
- “File not found.” appears often while navigating wp-admin
- WordPress Error blank page In section website
- Posts, pages and some images are deleted sometimes
- Call to undefined function wordpress listing_categories
- how do i fix these errors my debug log gave me?
- Undefined index when saved to options
- Fatal error: Call to undefined function wp_add_privacy_policy_content() in /wp-admin/includes/misc.php on line 1822
- The TypeError: this.each when wp.media.open() after using popper.js for bootstrap 4
- Unable to customize themes in wordpress after migrating to https from http
- A SINGLE Post Giving an “Under Maintenance” Message
- Can too-large images cause Error Establishing a Database Connection
- Weird Cron Error
- Error messages generated in ‘Customize Your Site’
- Overcome illegal characters [duplicate]
- How to find which plugin crashes
- Undefined Index. But isset not working?
- bypassing permission error for a plugin’s page
- Website Loading Very Slow, Each Time Different File Takes Very Long To Load
- Fatal error: Allowed memory size of bytes exhausted (tried to allocate 36 bytes)
- Logging out gives 404 error
- Any idea on how to fix this error when forcing SSL on a certain page?
- Internal 500 error: Activating rootio theme and deploying with capistrano
- White background, black text – the simplest on earth : “error”!
- Twenty Eleven theme-options error
- warnings & errors after MAMP to live (hosteurope)
- Random HTTP 500 error in WordPress
- I’m getting Call to undefined function wp_parse_list() out of the blue
- Add clickable function in functions.php – parse error [closed]
- Trying to add function with pre_get_posts for plugin search [closed]
- undefined index [closed]
- Language of errors in WordPress admin
- WordPress is not sending the 2nd email in the same request
- syntax error, unexpected ‘=>’ (T_DOUBLE_ARROW) [closed]
- Error code 499 on specific cron job
- Please Help Me, How to Fix PHP Error Undefined Array Key “srcset”
- My websit dosent worke http errors 500
- 403 forbidden in admin console: fix seems to be temporary and then error is back