0

Possible Duplicate:
Remove navigation from header in custom page template

Is there some way to remove wp_nav_menu in a page template? I can't find anything related to page templates other than redirect default theme files etc.

I know that just placing the header.php content in the page template will do the trick but this seems a awkward hack.

Thanks for any clue.

0

1 Answer 1

3

Without knowing your theme, you have at least a few options. You could 1. hide it with CSS.

.your-page-template-php #your-menu {
  display: none;
}

Or 2. you could create a custom header file. For example, duplicated header.php to header-nomenu.php. And in your new file delete the menu. And then in your page template instead of calling

get_header();

you'd call

get_header('nomenu');

EDIT

Upon further review there is a filter inside the wp_nav_menu function. Conditional logic will probably work as long as you haven't messed around with the query object and forgot to reset it.

function wpa76334_filter_nav_menu($menu, $args){
    if( is_page_template('your-template.php')) $menu = null;
    return $menu;
}
add_filter('wp_nav_menu','wpa76334_filter_nav_menu', 10, 2);
5
  • Hi, I'm hidding with css :S
    – Diana
    Dec 17, 2012 at 6:04
  • 1
    The answer I've just provided here should work: Similar Question. Dec 17, 2012 at 7:12
  • Good answer @JeremyJared. That would work perfectly in a custom theme or anywhere else you are cool with editing header.php. Looks like this question is a duplicate then. Dec 17, 2012 at 19:11
  • I thought there is some filter to prevent functions in template pages :( that's ok.
    – Diana
    Dec 18, 2012 at 14:00
  • You were right actually. There is a filter in wp_nav_menu. Let me edit my answer. Dec 18, 2012 at 20:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.