You could make sure the index is defined before accessing it in header.php,
and fallback gracefully:
<?php
$theme_option = flagship_sub_get_global_options();
if ( array_key_exists( 'flagship_sub_shield', $theme_option ) ) {
$shield = $theme_option['flagship_sub_shield'];
} else {
$shield = 'option1'; // Default value
}
if ('option2' === $shield):
//Image Option #2
elseif ('option3' === $shield):
//Image Option #3
else:
//Image Option #1
endif; ?>
Another possibly better option – to avoid having to include this check everytime you are getting a setting from $theme_option – would be to review your flagship_sub_get_global_options()
function and make sure it returns an array that includes every setting, including default values for those settings that are not saved in the database yet.
Related Posts:
- How to export/import theme customizer settings?
- Site Title and Tagline in Theme Options Page
- Show content if parent page has children
- reason of splitting theme files to multiple files
- Editor role cannot save custom theme options
- wp_customize_image_control default value
- Current post’s author name in the author meta tag
- Site Title and Tagline in Pagelines DMS Options Panel
- Conditional statement for parent, child and grandchild pages
- Trying to use Ternary operators with WP Conditionals
- How to override .htaccess with new rules without ftp or edit it manual
- How can one utilize a variable as a callback function name for add_settings_field
- When is is_admin() available?
- Check if current page is wp-admin
- Second Navigation inside header
- theme options echoing multiple times
- Using is_page() in functions.php not working at all
- Theme Options: If There is No Input, Don’t Display?
- Output 2 items within the Loop
- conditional statement for custom taxonomy
- How to enqueue CSS and JS only on specific template?
- Displaying theme options in css
- max_input_vars: how many am I using?
- Putting PHP variables into javascript [duplicate]
- Choose To Display Post Views With An Options Panel
- Set WordPress Default Template
- Set the checkbox as checked by default at options page
- Customizer – Prefix Class Extension
- Theme Options Page – User Updates Logo
- how could I load a different template part by page
- Selectbox in admin panel function linking to CSS
- Using if/else statements with output from theme options
- WP Post-Thumbnail
- WordPress, AJAX and pre_get_posts using conditional tags
- Error: options page not found
- WordPress theme options error
- If tag equals then show else show
- WordPress Options Page Theory Question
- Conditional statement for dates
- How can I display a div ONLY if it is not a certain term page
- Warning: Illegal string offset on theme options page [closed]
- Changing the color scheme based on the url visited
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- Don’t show certain div on front page?
- If ‘editor’ is empty, then
- Add class to DIV depending on page loaded
- Link blogname and blogdescription to the Options Framework
- How to add drag and drop functionalities to a div inside option panel
- How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)
- Remove conditional tag from header
- Display an image based on field value
- Multidimensional Array
- PHP if have image display image, if else text
- “if parent category is” conditional?
- Php file that doesn’t recognize wordpress functions
- Deactivate a plugin on wp version
- Conditional for Post Format
- conditional: if is page, and all subpages
- Woocommerce getting top level category parent and make all sub categories have the same template and menu
- page 1 is not paged
- what does $options = get_option(‘test_theme’); do?
- Using theme options to change a border-radius value
- Dynamically switch file in get_template_directory_uri() | Function [closed]
- Illegal string offset in PHP function in via Theme Customizer
- How to add Text before my Custom Term and hide it when empty
- How can i create a function tag in my plugin
- Add code to the header of posts by particular author
- Change CSS Variable value in Theme Customizer Live Preview
- Display specific page if user signed in
- How to get Post sidebar & footer including html like get_the_content() which only gets content section?
- How to find php variable of wordpress theme settings
- Widget Logic – display on page and all child
- Need to adjust condition to say if I’m pulling categories from a post, to pull only the first one
- if user is admin display admin link and logout link else display logout only
- Add code only for blog posts
- How to define Og Meta Tags in header using conditions [duplicate]
- If Month=Particular month display content [closed]
- wp_customize_image_control default value
- WordPress Setting page can not be saved by html radio
- Not able to call class in NHP framework
- How to echo a different field if another field is empty?
- Adding else if conditional statement to purchased theme
- Category List in Theme Options Page
- How to change a specific character in a theme option value – replace a space with a plus sign
- Conditional in foreach loop is outputting content twice
- Setting field not saving on front-end
- Select area and checkbox data is not saving?
- Advanced custom fields Repeater conditional statement not working [closed]
- Load slideshow.css file only if Slideshow is checked / on
- Options.php loop won’t show!
- Issues trying to add a href statment with PHP into a PHP Echo Statement [closed]
- if is specific custom post in cpt
- advanced custom fields: repeater field within conditional statement [closed]
- WordPress Block Editor Gutenberg running code inside ! is_admin()
- Woocommerce: How to override core functions in functions.php?
- Can I add the post featured image to a specific RSS feed?
- From php web to wordpress conversion, href changes only in URL
- What’s the correct offset value for order ASC?
- How to solve 404 permalink errors on nginx server
- WPMU schedule doesn’t execute actions