• Hi
    I need to load different headers for different pages of my site: one header called catalog, the other artisteditions. All else should have the standard homepage header.

    I tried the wp reference for it:

    if ( is_home() ) :
    get_header( ‘home’ );
    elseif ( is_404() ) :
    get_header( ‘404’ );
    else :
    get_header();
    endif;

    I transformed it into:

    if ( is_catalog() ) :
    get_header( ‘catalog’ );
    elseif ( is_artist-editions() ) :
    get_header( ‘artisteditions’ );
    else :
    get_header();
    endif;

    but it doesn’t seem to work. Please, how do I adapt this code correctly?

    many thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You can’t do it that way; is_home() and is_404() are built-in WordPress functions and you can’t just rename them. Instead, try something like:

    if ( in_category( 'catalog' ) ) :
        get_header( 'catalog' );
    elseif ( in_category( 'artist-editions' ) ) :
        get_header( 'artisteditions' );
    else :
        get_header();
    endif;

    That code checks if the current post that’s being displayed is in the specified category, and if it is, display the appropriate header.

    Thread Starter pedronmarques

    (@pedronmarques)

    Thanks!
    I feel i’m closer to solving this.

    I understand the logic, but for some reason it’s not working. But if I insert get_header(catalog) it shows “catalog” in the category page headers.

    I’m inserting this at the beginning of my page.php.
    Also I’m using a ecommerce plugin: shopp. I hope it’s not that that’s making things difficult…

    thanks!

    For this to work, you need three separate header files: header.php, header-catalog.php, and header-artisteditions.php.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘different headers for different pages code not working’ is closed to new replies.