Home › Forums › Support › using hooks on a template page This topic has 5 replies, 2 voices, and was last updated 5 years, 1 month ago by Leo. Viewing 6 posts - 1 through 6 (of 6 total) Author Posts April 16, 2021 at 7:45 am #1737193 Davide Hi, is there a way to use an hook (in this case generate_menu_bar_items) only on a custom template? Under the “display rules” in the Element menu there isn’t this possibility, so I guess it should be added via code (using something like https://developer.wordpress.org/reference/functions/is_page_template/ ? I’m not sure). Any hint? thank you! David April 16, 2021 at 4:44 pm #1737485 LeoStaff Customer Support Hi David, Not 100% sure what you are after but would this filter be helpful? https://docs.generatepress.com/article/generate_hook_element_display/ It can be used when the display rules don’t cover the condition you are after. Let me know 🙂 April 17, 2021 at 3:47 am #1737755 Davide Hi Leo, thank you. not sure about that https://docs.generatepress.com/article/generate_hook_element_display/ but I’ll check it out on Monday. I’m trying to display a “generate_menu_bar_items” hook on pages which are using the template (let’s say) layout-example.php. Maybe this could be achieved directly in the template (layout-example.php) itself.. thanks. Have a nice weekend David April 17, 2021 at 10:12 am #1738265 LeoStaff Customer Support Perhaps something like this? add_filter( 'generate_hook_element_display', function( $display, $element_id ) { if ( 10 === $element_id && is_page_template( 'layout-example.php' ) ) { $display = true; } return $display; }, 10, 2 ); April 20, 2021 at 4:09 am #1741417 Davide Hi Leo, perfect, thanks! David April 20, 2021 at 6:06 am #1741535 LeoStaff Customer Support No problem 🙂 Author Posts Viewing 6 posts - 1 through 6 (of 6 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In