Undefined index for default custom theme option

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 … Read more

Shortcode don’t work in custom option field, any solution?

If you have a shortcode string saved, try echoing it with do_shortcode function, which turns shortcodes into content. $saved_shortcode = get_option( ‘my_customizer’, ‘copyright’ ); if ( $saved_shortcode && is_string( $saved_shortcode ) ) { echo do_shortcode( $saved_shortcode ); } More about the function on the developer handbook, https://developer.wordpress.org/reference/functions/do_shortcode/ EDIT Another option is just echo the year … Read more

Show some menu sub items as dropdown under a menu item

Remove the first closing </li> and wrap the sub-items inside <ul></ul>, then close the parent <li>. For Example: function my_custom_menu_item($items, $args) { if(is_user_logged_in() && $args->theme_location == ‘primary’) { $user=wp_get_current_user(); $name=$user->display_name; $items .= ‘<li><a href=””>’.$name.'</a>’; $items .= ‘<ul>’; $items .= ‘<li><a href=”http://wordpress.stackexchange.com/my-profile”>My Profile</a></li>’; $items .= ‘<li><a href=”http://wordpress.stackexchange.com/my-posts”>My Posts</a></li>’; $items .= ‘<ul>’; $items .= ‘</li>’; } return … Read more

Parent page shows no child content

I just installed a fresh copy of WordPress and tried to create one parent page Pages are just pages, there’s nothing special about parent pages, and it’s not a term normally used but the page shows no content If the page has no content, then there is no content to show regardless of which Official … Read more

Check if( selected() )

selected is just an equals if statement that outputs selected or not. It doesn’t perform any special checks, it just makes the code for <option> tags a bit nicer. Without the selected function, you’d need to use a ternary operator, or temporary variables, the code for outputting forms would be awful. As the official docs … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)