Archived topic
Navigation Bar below featured image?
9 replies · Started by Cassie Thomas on February 1, 2015
Is there a way I can place my secondary navigation bar below a featured image on each page?
I would like for each page to have a unique featured image or header/logo image. I have all the add ons. Is there a way I can do it with a combination of these?
I originally bought the "Hook" pack but realized you could not change the hook for each page...
I tried changing the header logo/image, but again can't change it for each page.
Tried uploading a featured image on each page, and hiding the header image but then the navigation bar sits at the top of the website and not below the featured image.
Any suggestions would be appreciated.
Hi there,
You can try this PHP code which you can add using a plugin like this: https://wordpress.org/plugins/code-snippets/
add_action('after_setup_theme','generate_change_secondary_nav_position');
function generate_change_secondary_nav_position()
{
remove_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 7 );
add_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 30 );
}
In order for the above to work, your Secondary Nav position must be set to below the header.
Let me know :)
Thanks Tom,
This worked great. Only thing I realized is that the main navigation is now at the top. Is there a way I can move both the main navigation and the sub navigation to go below the featured image.
Thanks
This code should work:
add_action('after_setup_theme','generate_change_secondary_nav_position');
function generate_change_secondary_nav_position()
{
remove_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 7 );
remove_action( 'generate_after_header', 'generate_add_navigation_after_header', 5 );
add_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 30 );
add_action( 'generate_after_header', 'generate_add_navigation_after_header', 29 );
}
Brilliant. Works like a charm. Thank you for your help.
You're welcome :)
Hi. I'm using the secondary navigation in the header with a custom menu link to our forum, so I can't use it above the content, so I'd like to find another way to have a featured content headline directly below (or possibly inside) the featured image and above the content. I found this code and it works in the "inside content container" hook box, except that the headline wraps over the content and bumps against the right sidebar, and I need it to stretch the length of the featured image above the content and the sidebar. Moving it to the "after header" hook puts it above the featured image. Any way to alter this code slightly to achieve the effect I need? (Or is there an easier way to create a featured content headline that spans the full width of the container above the sidebar? Sorry if I'm missing something obvious.) Thanks much again.
<?php wp_reset_query(); ?>
<?php if ( is_front_page() ) : ?>
<h1 class="entry-title" itemprop="headline">Welcome to see the lazy brown fox jump over the moon with the cow and mrs. jones</h1>
</header>
<?php endif; ?>
If I'm understanding correctly, I think the generate_before_main_content hook is what you want.
You can see how to use hooks (without GP Hooks) here: https://generatepress.com/knowledgebase/hook-list/
Let me know if you need more info :)
I am using a child theme and trying to push the sidebar under the featured image too. I get a warning when I paste your code to my functions.php … apart of Gutenberg and PHP7 I got nothing fancy going on.
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'generate_add_secondary_navigation_after_header' not found or invalid function name in /XXXXXXXXXXX/wp-includes/class-wp-hook.php on line 286
Best regards
This is a super old topic - it would be best if you could start a new one with more info on what you're trying to do.
Thanks!