• Resolved breathelifein

    (@biellebrunner)


    I’ve been trying to set a header for the index/front page of my site, but then having a different header when you navigate to pages 2, 3,… and so on, as well as for single posts and pages.
    I’ve tried using on my header.php

    <?php if ( is_front_page() ) :
      get_header('header-main.php');
    else :
      get_header('header-pages.php');
    endif; ?>

    It works fine for single posts (castlebrasil.com/site/2013/11/castle-no-peoples-choice-award-2014/), pages (castlebrasil.com/site/a-serie/spoilers/), tags, and so on.
    But on page 2 (castlebrasil.com/site/page/2/), I still get the same header as on the front page.

    I’ve researched, and found this Referenced page: https://codex.www.ads-software.com/Function_Reference/is_paged
    But I can’t for the life of me figure out how configure this <?php is_paged(); ?> so it works the way I need it to.

    Any help would be much appreciated. Thanks.
    (And I apologize if there’s anything broken, since the site’s still under construction.)

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Try it with this:

    <?php
    if ( is_front_page() ) {
        if ( !is_paged() ) {
            // first page
            get_header( 'header-main.php' );
        } else {
            // paged page
            get_header( 'header-pages.php' );
        }
    }
    ?>

    Thread Starter breathelifein

    (@biellebrunner)

    It does work on pages 2, 3, and so on, but it stopped working on single pages/archive/etc.
    So I just called <?php get_header('pages'); ?> instead of <?php get_header(); ?>, and that did the trick.
    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Different headers on front page and on pages 2 and on’ is closed to new replies.