Three different header options


I am a beginner PHP coder and hitting a brick wall on how to write this if and statement:
I need to write options for three different header scenarios;

  1. Display standard header if NOT the homepage or, if one of these pages then;
    2)  display header two, or if;
  2. on the homepage, display none

Here is my very newbie college try:

<?php if (!is_front_page()) : ?>
    <?php echo roots_title(); ?>
; } elseif ( is_page( 'home-en', 'home-es' ) ) {
     display  header 2
  </h2>; } 
<?php endif; ?>

This really isn’t the place for learning PHP, but I’ll leave the thread open for a day to see if you get lucky.

It’s your luck day. This should work, but please heed @Foxaii’s comment. This is not the place for PHP support/learning.

<?php if(!is_front_page()) : ?>
  <?php if(is_page(array('home-en', 'home-es'))) : ?>
    <!-- You need to create this file, see below -->
    <?php get_template_part('templates/header-two'); ?>
  <?php else : ?>
    <?php echo roots_title(); ?>
  <?php endif; ?>
<?php endif; ?>

Note that I stripped your markup but left it markup friendly. Also, you will need to create templates/header-two.php and place your markup/code for that custom header in there.


1 Like

Thanks guys, You rock! Appreciate it.

This topic was automatically closed after 24 hours. New replies are no longer allowed.