Archived topic
Different menu layout for homepage
9 replies · Started by Matteo on January 2, 2020
I have setup a layout for the primary menu, but it affects the whole site. I'd like to keep the same menu but change the layout only for the homepage. In the homepage I prefer the classic menu style with the logo/name on the left and the menu on the right (desktop view, obviously), as it's set by default.
Can you help me?
Hi there,
Try this PHP snippet:
add_filter( 'option_generate_menu_plus_settings', function( $settings ) {
if ( is_front_page() ) {
$settings['navigation_as_header'] = 'true';
}
return $settings;
} );
Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know if this helps :)
Good, but the name should be aligned to the left and the menu to the right.
Looks like it is?
https://www.screencast.com/t/9sVsUoaOCtnE
Yes, now the name and the menu appear like in the screencast you made: centered.
I'd like the name "Matteo Spigolon" aligned to the left and the menu aligned to the right.
Try this CSS:
.home.nav-aligned-center .navigation-branding {
margin-right: auto;
}
It doesn't work.
I'm not seeing the CSS added.
When I add it using browser inspect, it's working:
https://www.screencast.com/t/ieIgBRPEyiZ
Now it's work. Thanks.
No problem :)