I have a sidebar that displays child links of the current page (using this solotuin by https://wordpress.stackexchange.com/a/2809/27414) which works perfectly.
If there is child links to be displayed in the side bar I would like to give it a heading such as “Also is this section”.
I have tried the following which didn’t work:
if (wp_nav_menu( $args )){
echo "Also in this section";
}
Thanks
Use
has_nav_menu
to check if a location has been assigned a menu or nothttp://codex.wordpress.org/Function_Reference/has_nav_menu
For more advanced checks you’ll need to do a call to
wp_get_nav_menu_items
and process the items it returns to see if any of them are children.Here’s an example outputting a menu that shows how to use its output:
A vital thing to note is that a nav menu is made out of nav menu items, and these menu items are custom post types. Use the parent child association to determine the depth, just as you would with pages and posts