Archived topic
primary menu inside the content
11 replies · Started by Daniele on March 27, 2019
Hi all,
I'm tring to find a solution to put my primary menu inside the content.
as here: http://www.80s.it/wp-content/uploads/2019/03/Senza-titolo-2.png
any idea?
tnx in advance,
Daniele
Hi there,
This should be pretty easy.
Try this PHP:
add_filter( 'generate_navigation_location', function() {
return 'custom';
} );
add_action( 'generate_before_main_content', function() {
if ( function_exists( 'generate_navigation_position' ) ) {
generate_navigation_position();
}
}, 1 );
Hi Tom,
it seems working properly just on pages (please see http://www.80s.it/contatti/ ) but on the homepage the menu is hidden by the content and in blog pages the menu is showed in the header.
I tried to put your code in a hook (i thought the hook would be the easiest way to show the menu, even because in the future i could choose to use it on the top of the sidebars) but it doesn't work at all...
I just updated the code above - can you give it another shot?
It should be added using one of these methods: https://docs.generatepress.com/article/adding-php/
:D It is just as perfect as usual.
Just to be clear, i've added the code inside the functions.php file, but i was just figuring out if that code, modified like that
add_filter( 'generate_navigation_location', function() {
return 'custom';
} );
add_action( 'generate_before_right_sidebar', function() {
if ( function_exists( 'generate_navigation_position' ) ) {
generate_navigation_position();
}
}, 1 );
would easily work as well in other part of the website using hooks.
I'll try.
Thanks again and have a nice day,
Daniele
Glad I could help! :)
This code is not working for my themes. This is the website https://www.gulfstatesoftware.com/.
First I use function.php then I'm using code snippet. But nothing works.
-Thanks
Do you have the navigation as a header option enabled?
If so can you disable it first?
https://docs.generatepress.com/article/navigation-as-a-header/
Looks like process is change with the development of theme.
-Thanks a lot.
Sounds good.
Sorry , I disable the navigation header , but now if I past the code in function.php, they navigation bar went out.
Hi there,
this is quite an old topic and since then there have been some changes... and i am not sure if that code is what you would need today - the code is removing the nav from its current location and placing it before the Right Sidebar... which your site is not using.
Could you raise a new topic and explain exactly where you want the navigation to be positioned and we'll work that out