• Hi! I am trying to change the header template using the get_header action but it wont change anyway I try to do it.

    Here is what I tried:

    
    function prefix_new_header() {
        return 'newtmpl';
    }
    add_action( 'get_header', 'prefix_new_header' );
    

    I have in the theme folder a file called header-newtmpl.php

    I’ve tried different priorities (1, 10, 99), but it doesn’t work.

    Is there something I am missing? Thanks for any help!

    • This topic was modified 8 years, 6 months ago by superskill.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi, @superskill. If the goal here is to load header-newtmpl.php as the theme’s header template, then in each of the Template Files where you want to use it, you’d simply do this:

    get_header( 'newtmpl' );

    • This reply was modified 8 years, 6 months ago by girlieworks.
    • This reply was modified 8 years, 6 months ago by girlieworks.
    Thread Starter superskill

    (@superskill)

    Hi @girlieworks! Thanks for the reply. I know about get_header( 'newtmpl' );, my issue isn’t that. The goal is to change the theme’s header, but wouldn’t it be easier to manage all this with that action hook.

    If I add a select box in my theme to choose from different headers, I would like to use that hook instead of doing something like:

    
    $header_name = get_theme_mod('option_name');
    get_header( $header_name );
    

    The above code would mean that I have to add $header_name in every file where get_header() is.

    • This reply was modified 8 years, 6 months ago by superskill.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_header action not working’ is closed to new replies.