Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wordpress is_home() || is_index() possible?

Tags:

php

wordpress

I have a test in my header.php to see whether we are at home to display a hero or not.

<?php if ( is_home() && have_posts() ) : ?>
  <div id="hero" class="inner clearfix">
    ...
  </div>
<?php endif ?>

But when the user lands on index.php the hero is not being shown. apparently there is no is_index() condition, does anyone know how I could test for if its home or index?

like image 762
Stefan Avatar asked Jul 14 '11 21:07

Stefan


1 Answers

Try is_front_page()

<?php if ( is_home() || is_front_page() ) : ?>
  <div id="hero" class="inner clearfix">
    ...
  </div>
<?php endif ?>

That should return true if you are on the absolute root of site.

like image 199
brenjt Avatar answered Nov 01 '22 23:11

brenjt