- This topic has 23 replies, 3 voices, and was last updated 7 years ago by
Leo.
-
AuthorPosts
-
May 21, 2019 at 2:26 am #906387
Sebastien
Hi,
I would like to implement a Menu item called “NavServiceBar” into a GP Element > Hook > after header.
Also, I would like to display this menu item ‘inline’ instead of verticaly.
How can I do please?Thanks
May 21, 2019 at 7:45 am #906800David
StaffCustomer SupportHi there,
why not use the Secondary Navigation?
May 21, 2019 at 7:52 am #906806Sebastien
Can I ?
I’ve linked to my initial post, a link to the page.The position where I want to display this Menu item, is between the header and the breadcrump (where it is written: nav)
note: the header is generated by a GP element Header.May 21, 2019 at 7:57 am #906808David
StaffCustomer SupportYes, so follow these steps:
1. Create New Hook give it a title.
2. Add this as the content:<div class="second-nav grid-container"> <?php generate_secondary_navigation_position(); ?> </div>3. Select the
after_headerhook
4. Check Execute PHP
5. Set the Priorty: 15
6. Set your display rules for the entire site ( or wherever )Then in Customizer > Layout > Secondary Navigation set Location: No Navigation.
Just make sure you have a menu assigned to the Secondary Nav.
May 21, 2019 at 8:14 am #906830Sebastien
I guess this line in wp-config
define('DISALLOW_FILE_EDIT',1);unables me to add PHP in GP Hook.
Is there something I can do to allow php only into GP Hook ?
Maybe I don’t understand, but I didn’t find the solution there https://docs.generatepress.com/article/disallow-php-execution/I’ve tried to add into function.php childthem:
add_action( 'after_setup_theme', 'tu_remove_hooks_php_check' ); function tu_remove_hooks_php_check() { remove_action( 'admin_notices','generate_hooks_php_check' ); }but the warning msg remains:
Unable to execute PHP as DISALLOW_FILE_EDIT is defined.May 21, 2019 at 8:54 am #906899David
StaffCustomer SupportLeo provides a function for hooking in the secondary nav here on point 4:
https://generatepress.com/forums/topic/creating-specific-header/#post-684673
May 21, 2019 at 9:15 am #906921Sebastien
Thanks,
add_action( 'after_setup_theme','lh_move_secondary_navigation' ); function lh_move_secondary_navigation() { remove_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 7 ); add_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 15 ); }This function hook a second nav under page hero in entire website.
Can I match this function with rules of a GP Element to display this function into specific pages only?
May 21, 2019 at 10:09 am #906966Leo
StaffCustomer SupportYou’d have to use conditional tags similar to this example here:
https://generatepress.com/forums/topic/different-logos-on-different-with-sticky/#post-875076Let me know 🙂
May 21, 2019 at 10:39 am #906994Sebastien
Hi Leo,
I’m not familiar with functions.1) Firstly I’ve tried this code to add the secondary navigation item under my header:
add_action( 'after_setup_theme','lh_move_secondary_navigation' ); function lh_move_secondary_navigation() { remove_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 7 ); add_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 15 ); }I’ve matched a menu to the secondary navigation and param the Navigation Location (into Customizer) : Hide secondary bar.
But nothing is displayed.
2) about the conditional tag I guess something like this would work? :
add_action( 'after_setup_theme','lh_move_secondary_navigation' ); function lh_move_secondary_navigation() { // Return our category logo URL if ( is_page( array( 1, 2, 3, 4, 5 ) ) ) { remove_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 7 ); add_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 15 );; } }May 21, 2019 at 10:47 am #906998Leo
StaffCustomer Support1. Try below header in the secondary navigation location
2. Yup that looks good. Just need to change replace
1, 2, 3, 4, 5to the actual page id or name:
https://codex.wordpress.org/Conditional_Tags#A_PAGE_PageMay 21, 2019 at 10:55 am #907004Sebastien
thanks Leo !!
It works I’m so happy 😀But last thing… This actual solution put the content in a div that is full width.
What I loved with GP Element Hook after header is that is put the content in a section (same width / margin than the body section)
Is there any way to do the same thing?May 21, 2019 at 11:30 am #907040Leo
StaffCustomer SupportWhat if change the widths to contained?
https://docs.generatepress.com/article/secondary-navigation-layout/May 21, 2019 at 11:45 am #907048Sebastien
Thanks you guys for your support!
GP is so powerfull everysecond it surprises me 😮Edit:
the conditional function doesn’t work:add_action( 'after_setup_theme','lh_move_secondary_navigation' ); function lh_move_secondary_navigation() { if ( is_page( array( 4536, 4537, 36, 4538, 4534, 4535 ) ) ) { remove_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 7 ); add_action( 'generate_after_header', 'generate_add_secondary_navigation_after_header', 15 );; } }when I use this code, the secondary navigation is displayed under the top bar instead of after header.
May 21, 2019 at 11:58 am #907063Leo
StaffCustomer SupportHmm was it working before the conditional tag was added?
May 21, 2019 at 11:58 am #907064Sebastien
yes
-
AuthorPosts
- You must be logged in to reply to this topic.