I made a Navigation (primary) via Appearance->Menus which navigates the user to anchor tags on the side, but I also have subpages, where I want a different navigation - only with my 'Home'-button in it. Which would mean I need to get rid of the other navigation points.
I did create another sub-navigation for the subpages, but don't know how to get it up.
My header.php
shows me
<php if (has_nav_menu ( 'primary') ) : ?>
Can i just do an else
with another navigation?
My Theme only supports one menu though ...
Big thanks for the help! :)
I made a Navigation (primary) via Appearance->Menus which navigates the user to anchor tags on the side, but I also have subpages, where I want a different navigation - only with my 'Home'-button in it. Which would mean I need to get rid of the other navigation points.
I did create another sub-navigation for the subpages, but don't know how to get it up.
My header.php
shows me
<php if (has_nav_menu ( 'primary') ) : ?>
Can i just do an else
with another navigation?
My Theme only supports one menu though ...
Big thanks for the help! :)
Share Improve this question edited Mar 28, 2019 at 20:46 Kalex asked Mar 28, 2019 at 16:48 KalexKalex 135 bronze badges 7 | Show 2 more comments2 Answers
Reset to default 0It doesn't sound like you need another Navigation menu.
How about something like this:
<?php if ( is_page() && $post->post_parent > 0 ) {
// we know we are on a sub/child page now...
// PS. another way to handle this would be to check if you were on a particular page template or particular page ids etc.
?>
<a class="awesome-button" href="<?php echo esc_url( home_url( '/' ) ); ?>">Go home!</a>
<?php
// just show a link Home for the subpages...
} else {
// now we are NOT on a subpage, so show the Primary nav menu...
wp_nav_menu( array('menu' => 'primary') );
} ?>
Hi @Kalex you can use the get_header
for your custom header.php file. You can get the example code from here: https://developer.wordpress/reference/functions/get_header/ .
The combination of Template Name with Custom Header is very make sense for this case (if I understand right your question).
header.php
or elsewhere...? Also, the different navigation you referred to: how different is it? (1) entirely different, or (2) adds a one or two links to the original nav, or (3) removes one or two links...? The more information you can provide the better (and faster) answers you will get from the community here. And don't worry about being a beginner: everyone here was once a beginner. – jsmod Commented Mar 28, 2019 at 17:12header.php
file? If yes, you might want to consider creating a child theme before you continue because any changes you make to the original (parent) theme will be gone when that theme is updated. A child theme will preserve the changes you make. – jsmod Commented Mar 29, 2019 at 20:30primary
menu on only the index/home page is suggested in an answer below by Monkey Puzzle. If that works for you, please mark it as answered so others searching for the same thing can easily see the solution. – jsmod Commented Mar 29, 2019 at 20:31