Tagged: anchors, blog post, navigation
Not sure how to go about this: if I have a single-page site with anchors in the navigation, how do I add a blog that links back to the page? Currently, if you click to view a blog post, the navigation no longer works obviously due to it tied to anchors. Is there a way to work around this? Is a second menu bar for blog posts?
Hey Snerp,
Thanks for contacting us!
You can use this plugin to display different menu on certain pages – https://wordpress.org/plugins/zen-menu-logic/. You could create another menu with full links and set it as your main menu and then on your homepage you can choose to display menu with anchor links.
Regards,
Yigit
The plugin is outdated by 4 years, I’m going to skip it.
You’re other suggestion I’m not sure I understand. Do you mean I need to create a full links menu as the “Enfold Child Main Menu” and another menu to be the “Enfold Child Secondary Menu” that uses the anchors? If so, how do assign each menu (one for the home, the other for the blog).
Thanks
Hi,
Then create a new menu with full links and add following code to functions.php file of your child theme
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
function my_wp_nav_menu_args( $args = '' ) {
if($args['theme_location'] === 'avia')
if( is_page( 12 ) ) {
$args['menu'] = 'Anchor Menu';
} else {
$args['menu'] = 'Full Menu';
}
return $args;
}
“Full Menu” would be the name of your new menu and “Anchor Menu” is the name of the one you used on your homepage and 12 is the page ID of your homepage
Best regards,
Yigit
You da man! Thanks, that is a great tweak. You guys should add this to your documentation…very helpful.