[Resolved] Using generate_before_header hook to pull a global navigation php file

Home Forums Support Using generate_before_header hook to pull a global navigation php file

  • This topic has 3 replies, 2 voices, and was last updated 1 month ago by Tom.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1406578
    Michael

    We have a multisite install that requires a global navigation to display at the top of all of our child sites of our multisite install (above the header). I’ve made sure that the global_nav.php file is located in an inc directory located within the child theme folder. In the functions.php file I’ve tried to include the global navigation using the following:

    /* Include global navigation*/
    add_action( 'generate_before_header','global_nav' );
    function global_nav() { ?>
    	include_once ( get_stylesheet_directory() . '/inc/global_nav.php' );
    <?php }

    The hook seems to work but just displays the following code and not the menu:

    include_once( get_stylesheet_directory() . ‘/inc/global_nav.php’ );

    I’m sure its something simple I’m missing but I just don’t see it.

    #1406846
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You’ve closed PHP, so it’s rendering your PHP as regular text.

    Try this:

    /* Include global navigation*/
    add_action( 'generate_before_header','global_nav' );
    function global_nav() {
    	include_once ( get_stylesheet_directory() . '/inc/global_nav.php' );
    }
    #1408317
    Michael

    Dang. Thanks Tom! Much appreciated.

    #1408320
    Tom
    Lead Developer
    Lead Developer
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.