• Resolved leonardochen0

    (@leonardochen0)


    I’m trying to create a shortcode that will output the contents of one of my template header files.
    I thought I just needed to create it in my functions.php file

    function zoo_header(){
    	return 'test'.get_header('navbar');
    }
    add_shortcode('zoo-header', 'zoo_header');

    And use it in my templates: [zoo-header] or do_shortcode(‘[zoo-header’])

    However, the output of the shortcode is simply ‘test’
    Why is the content of my header not showing up?

    header-navbar.php

    <?php wp_nav_menu( array(
    	'theme_location' => 'right-menu',
    	'container' => false,
    	'menu_id' => 'navbar-right',
    	'menu_class' => 'nav navbar-nav navbar-right'
    )); ?>
    <p>testing 123</p>

    It’s as if get_header is not returning anything.
    I have 2 headers that I need to show, and I wanted to give the template authors the option to choose between one or the other.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Shortcode to output get_header’ is closed to new replies.