• Resolved josh5723

    (@josh5723)


    I’ve searched a bunch on this issue and have found many people giving different advice. I will only need 2 different header files for my site, the original and the new one I’ve since created (titled header-second.php).

    I’ll want header-2 to appear on multiple pages, identified by their Page ID. How do I accomplish this the easiest? An if tag in the index.php file?

    This is included on the multiple headers page:

    <?php
    if ( is_home() ) :
    	get_header( 'home' );
    elseif ( is_404() ) :
    	get_header( '404' );
    else :
    	get_header();
    endif;
    ?>

    How do I alter this for specific page IDs? I’ve tried adding this to index.php, but it changed nothing and still loaded the original header.php.

    <?php
    if ( is_page(417) ) :
    	get_header( 'second' );
    else :
    	get_header();
    endif;
    ?>

    Do I need to add this code to all .php files where get_header is present? What am I doing wrong?

    Thanks a lot!

Viewing 1 replies (of 1 total)
  • Thread Starter josh5723

    (@josh5723)

    Update: So I figured out an issue. I was updating index when I should’ve been updating the page.php file since I’m primarily wanting pages to load the different header file.

    I figured it out. If anyone else has the same issue, both of the following pieces of code work to update page.php (or whatever other page you want, such as categories or whatever).

    Single Page:

    <?php
    /**
     * The main template file.
     * @package WordPress
     */
    if ( is_page(430) ) :
    	get_header( 'bellevue' );
    else :
    	get_header();
    endif;

    Multiple Pages:

    <?php if( is_page(array(417, 443, 430, 431, )) ) {
    echo get_template_part( 'header', 'bellevue' );}
    else {
    echo get_header(); } ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Load New Header File On Certain Pages’ is closed to new replies.