Wordpress Error Handling when no menu location assigned -
my menu code
<h6><?php $theme_location = 'footer-customers'; $theme_locations = get_nav_menu_locations(); $menu_obj = get_term( $theme_locations[$theme_location], 'nav_menu' ); echo $menu_obj->name; ?></h6> <?php $footer_02 = wp_nav_menu( array('theme_location' => 'footer-business' , 'container' => '', 'echo' => false, 'fallback_cb' => '__return_false') ); if ( ! empty ( $footer_02) ) { echo $footer_02; } ?>
may know how check if there no menu assigned theme_location in backend setting(/wp-admin)?
the error msg follow:
how make title become empty or show nothing if menu not set or assign
judging error i'm guessing line 78 echoing of $menu_obj->name?
if can following:
<h6><?php $theme_location = 'footer-customers'; $theme_locations = get_nav_menu_locations(); $menu_obj = get_term( $theme_locations[$theme_location], 'nav_menu' ); // check whether name property exists - return true if property // defined empty $bhavename = property_exists ( $menu_obj , 'name' ); // check both true , has length before accessing if($bhavename == true && strlen($menu_obj->name) > 0) { echo $menu_obj->name; } ?></h6>
reference: php manual