So I have a nice little Sub Nav Walker up and running that I have added to a navfunctions.php file which gets called from my main theme functions.php.

In my sidebar I then call a file subnav.php which executes the subnav walker:

relevant sidebar snippet:

<?php
load_template(TEMPLATEPATH . '/subnav.php');
?>

subnav.php contents

wp_nav_menu( array(
    'container' =>false,
    'theme_location' => 'Main Navigation',
    'sort_column' => 'menu_order',
    'menu_class' => 'tfsubmenu',
    'echo' => true,
    'before' => '',
    'after' => '',
    'link_before' => '',
    'link_after' => '',
    'depth' => 0,
    'walker' => new subnav_walker()
) );

The subnav_walker is perfect so no issues there.

The issue I have is that I'd ideally like to not execute the load_template call if there are no child menu items on the current page.

Is there a way I could wrap the load_template call in an if statement without calling the subnav walker?

e.g. something like:

<?php
if (!empty (wp_menu_menu_children)) {
    load_template(TEMPLATEPATH . '/subnav.php');
}
?>

I realise this is a long shot but any ideas would be a big help.

Thanks,

Ed

link|improve this question
Welcome to wordpress.SE. Have you looked into wrapping this into a if statement to check if there child pages: codex.wordpress.org/Conditional_Tags#Testing_for_sub-Pages – chrisjlee Aug 4 '11 at 22:22
@Ed - FYI: If you click that yellow circle with a question mark to the top right of the question/answer textarea you'll find a page on how to post code and format your question using markdown(which will help when trying to post code, etc).. – t31os Aug 5 '11 at 0:24
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.