Archived topic
Sticky Secondary Menu instead of Primary Menu
29 replies · Started by Abdul Rehman on June 30, 2017
Hi
How can I create sticky secondary navigation instead of primary? I can't switch the settings to make primary secondary and secondary primary one, since I am using navigational logo...
Hi there,
I would switch the settings so that the one you want sticky is the primary and then just add the navigation logo using GP hooks:
https://docs.generatepress.com/article/generate_inside_secondary_navigation/
Something like this:
add_action( 'generate_inside_secondary_navigation','lh_secondary_navigation_logo' );
function lh_secondary_navigation_logo() {
?>
<div class="secondary-navigation-logo">
<img src="URL TO NAVIGATION LOGO" alt="" />
</div>
<?php
}
I did not get the process. Can you please explain it in more detial?
In your original post, you mentioned that the setting cannot be switched since you are using navigation logo in primary navigation.
So the method above adds a navigation logo to secondary navigation so you can switch the setting.
Let me know if this makes sense.
I understood this part. I just don't know how to use the hooks. Where to insert the code etc
When I go to the hooks section, there are lots of windows. In which window should I insert the code?
I am already using this CSS. Shall I remove it?
.site-header {
display: none;
}
.main-navigation .sticky-logo,
.main-navigation .sticky-logo img {
width: auto;
}
/* Navigation logo */
.main-navigation .sticky-logo,
.main-navigation .sticky-logo img {
height: 55px;
}
.main-navigation .navigation-logo {
padding-left: 70px;
}
.main-navigation
padding-top: 100px;
That hook is actually not in the hooks module so add it as a snippet: https://docs.generatepress.com/article/adding-php/#code-snippets
You can keep that CSS for now. Might help adjusting the CSS once you add the logo into the secondary navigation.
Ok. I added code in functions.php file in my child theme. But I can't see any new hook category in hooks section.
What should I do next?
The code acts as the hook. If you replace URL TO NAVIGATION LOGO by the actual URL then it should show up.
actual URL here means?
URL of your logo image.
I put the URL of logo image. Still no new category visible in the hooks. By what name does new category appear?
I am already using this function
add_filter( 'generate_logo_href','generate_custom_logo_href' );
function generate_custom_logo_href()
{
// Enter the URL you want your logo to link to below
return 'http://www.elearnee.com';
}
Is this code interfering?