- This topic has 5 replies, 2 voices, and was last updated 2 years, 9 months ago by .
Hope you had a great holiday.
I seem to be having a problem with default meta values not doing what they are supposed to do.
OK, so as an example let’s say I have this metabox select field for the title of the post or page.
There are two options the user can chose from:
1. display title in the post (default, set with std)
2. display title in page header
Here is the code for that select field:
array ( 'id' => 'xxxxxx_page_header_title_position', 'name' => esc_html__('Post/Page Title Position','xxxxxx'), 'type' => 'select', 'column' => 'column-1', 'options' => array ( 'xxxxxx_default_position' => esc_html__('Display Title in Post','xxxxxx'), 'xxxxxx_page_header_position' => esc_html__('Display Title in Page Header','xxxxxx'), ), 'tooltip' => array( 'icon' => 'help', 'content' => esc_html__('Select where you would like to display the title. Default position is in the post/page or you can change the position to display in the Page Header.','xxxxxx'), 'position' => 'top', ), 'tab' => 'xxxxxx_featured_image_options_tab', 'std' => array ( 'xxxxxx_default_position', ), ),
(xxxxxx represents the name of the plugin, I changed it to add to this post)
Now in the theme I have the following:
<?php if ($xx_title_position === 'xxxxxx_default_position'): ?> display the title <?php endif; ?>
For some reason, once the metabox is activated the default option is not being set and the title disappears.
If I hit “update” in the editor, then go back to the post or page, the title will display
Trying to figure out why its not being set, how can I have it set automatically? Is it because it is an if statement?
- You must be logged in to reply to this topic.