sage icon indicating copy to clipboard operation
sage copied to clipboard

<?php if( is_home() ) : ?> Conditionals Not Working

Open expertpixels opened this issue 14 years ago • 7 comments

Hey all,

Sorry to post regarding this but i am trying to use some simple conditionals that work fine on other templates, but are not working with the roots theme.

These are the conditionals i am trying to use:

I mainly need the "is_home" to work.. I am guessing that the roots activation / cleanup process is effecting this somehow.. ive deleted the front-page.php file and am using the index.php / loop.php as my main template files..

Any help on this would be great.

Regards, Darren

expertpixels avatar May 05 '12 03:05 expertpixels

both are working fine over here. closing until more details are provided - sounds like a template hierarchy issue. if you try using the conditionals in header.php or footer.php you can easily see they're working as intended

retlehs avatar May 09 '12 03:05 retlehs

kk cheers mate... i'll look into it.. Again thanks for the awesome work you have put into this !!! more worried about getting this issues fixed: https://github.com/retlehs/roots/issues/426

expertpixels avatar May 09 '12 04:05 expertpixels

I am also having this issue. Using WordPress 3.4 and Roots 5.1.0, no child theme. Placing this code in the HEADER.PHP line 26.

<?php if ( is_front_page() ) : ?> 

works fine, however the following does not:

 <?php if ( is_home() ) : ?>

zumajoe avatar Jun 16 '12 18:06 zumajoe

Has anyone figured this out? Placing either in footer.php and can't get it to work. It omits the code, but wont load conditionally on front_page/home.

ghost avatar Jul 11 '12 12:07 ghost

I found a workaround to the problem. If you include before it seems to do the trick. Thanks!

ghost avatar Jul 11 '12 12:07 ghost

Thanks for posting your solution, will try this.

Regards, Darren

expertpixels avatar Jul 14 '12 04:07 expertpixels

I had the issue in the page-header.php template.

Added a wp_reset_query(); at the top of the file and it has fixed the problem. (hopefully won't cause other issues)

patforg avatar Jan 11 '17 12:01 patforg