Title: Issue with is_home() condition on WP 3.3
Last modified: August 20, 2016

---

# Issue with is_home() condition on WP 3.3

 *  [eva-MyClientIsRich](https://wordpress.org/support/users/eva-myclientisrich/)
 * (@eva-myclientisrich)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/post-thumbnails-sizes/)
 * Hello !
 * I’m working on a theme using **different thumbnail sizes on blog homepage**. 
   My code was working fine before the update. And now… It looks like the condition**
   if(is_home() && has_tag(array(‘place1’, ‘place2’, ‘place5’)))** does not work
   anymore… **When I remove the is_home() part, it works fine.** But I need it… 
   Here is the code.
 * **1st try**, working fine before WP 3.3 :
 *     ```
       <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
   
       	<div class='thumbnail-image'>
       		<a href='<?php the_permalink() ?>'>
       			<?php
       			if(is_home() && has_tag(array('place1', 'place2', 'place5'))) {
       					the_post_thumbnail('home-smallpost-thumbnail');
       			}
       			else{
       				the_post_thumbnail('home-bigpost-thumbnail');
       			}
       			?>
       		</a>
       	</div>
   
       ...
       ```
   
 * **2nd try** was this :
 *     ```
       if(is_home()) {
       	if(has_tag(array('emplacement1', 'emplacement2', 'emplacement5'))) {
       		the_post_thumbnail('home-smallpost-thumbnail');
       	}
       }
       ```
   
 * **3rd try** was the same, without the if(is_home()){} part (so only the has_tag()
   part) and **it works fine**…
 * I’m completely lost. Why should the **is_home()** condition break ? Did you experience
   this kind of problem lately ? Do you see any explaination ?
 * I hope to hear from someone soon !

Viewing 13 replies - 1 through 13 (of 13 total)

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/post-thumbnails-sizes/#post-2467244)
 * you may have used custom queries in you main section, which could have distorted
   the original query string and the idea of ‘home’ –
    try to add wp_reset_query();
   before your if ( is_home() ) or before your loop.
 *  [markparolisi](https://wordpress.org/support/users/markparolisi/)
 * (@markparolisi)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/post-thumbnails-sizes/#post-2467262)
 * since WP 3.0 you should use wp_reset_postdata()
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/post-thumbnails-sizes/#post-2467268)
 * [@markparolisi](https://wordpress.org/support/users/markparolisi/)
    Didn’t know
   that. There’s nothing on the codex page that it’s a deprecated function. [http://codex.wordpress.org/Function_Reference/wp_reset_query](http://codex.wordpress.org/Function_Reference/wp_reset_query)
 *  Thread Starter [eva-MyClientIsRich](https://wordpress.org/support/users/eva-myclientisrich/)
 * (@eva-myclientisrich)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/post-thumbnails-sizes/#post-2467351)
 * Hi ! Thanks for trying to help !
    Tried both solutions, and the same issue continues…
 * To be sure, I tried to use a regular php function, to get the current page (homepage)
   url and see if it matches my $homeUrl, and **it works**. The `is_home()` function
   is still not working, even when I reset queries… Until I find a solution about`
   is_home()`, I’ll use my function (which does the same).
 *     ```
       <?php
       $homeUrl = "http://mysite.com/";
       $myUrl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
       if($myUrl == $homeUrl && has_tag(array('place1', 'place2', 'place5'))) {
       	the_post_thumbnail('home-smallpost-thumbnail');
       }
       else{
       	the_post_thumbnail('home-bigpost-thumbnail');
       }
       ?>
       ```
   
 * Related question : are we allowed to use several times `is_home()` on one page(
   I use it once in header.php and was trying to use it in content.php) ? I read
   somewhere that it may cause some troubles… (I think it should not).
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/post-thumbnails-sizes/#post-2467354)
 * On what template file are you doing this. If this is a static home Page you maybe
   have to use is_front_page(): [http://codex.wordpress.org/Conditional_Tags#The_Main_Page](http://codex.wordpress.org/Conditional_Tags#The_Main_Page)
 * > are we allowed to use several times is_home() on one page
 * yes you are.
 *  Thread Starter [eva-MyClientIsRich](https://wordpress.org/support/users/eva-myclientisrich/)
 * (@eva-myclientisrich)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/post-thumbnails-sizes/#post-2467357)
 * I’m using `is_home()` on the blog homepage, not on a static page. And that’s 
   the blog which is configured as the home page. I also thought about `is_front_page()`
   but double checked that my blog was the homepage. That’s weird.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/post-thumbnails-sizes/#post-2467358)
 * So you’re using it in index.php?
 *  Thread Starter [eva-MyClientIsRich](https://wordpress.org/support/users/eva-myclientisrich/)
 * (@eva-myclientisrich)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/post-thumbnails-sizes/#post-2467359)
 * in `content.php` (it is a theme based on twenty eleven), which is included in`
   index.php`.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/post-thumbnails-sizes/#post-2467360)
 * Can you put this in index.php before the loop (for testing). Before `<?php if(
   have_posts() ) : ?>` if your index.php has that:
 *     ```
       <?php
       global $wp_query;
       echo '<pre>';
       print_r($wp_query);
       echo '</pre>';
       ?>
       ```
   
 * and see if you if is_home is set:
    `[is_home] => 1`
 *  Thread Starter [eva-MyClientIsRich](https://wordpress.org/support/users/eva-myclientisrich/)
 * (@eva-myclientisrich)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/post-thumbnails-sizes/#post-2467361)
 * Yes, the result is `[is_home] => 1` on index.php
 * Just to try, I pasted this in content.php, and it is not set there : `[is_home]
   =>`
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/post-thumbnails-sizes/#post-2467362)
 * Can you paste and submit the full code of index.php and content.php of your theme
   into a [pastebin.com](http://pastebin.com/) and post the link to it here? see
   the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code) for 
   posting code and using the pastebin.
 * Also try:
    – deactivating **all** plugins to see if this resolves the problem?
   If this works, re-activate the plugins one by one until you find the problematic
   plugin(s).
 * – switching to the default theme to rule out any theme-specific problems.
 *  Thread Starter [eva-MyClientIsRich](https://wordpress.org/support/users/eva-myclientisrich/)
 * (@eva-myclientisrich)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/post-thumbnails-sizes/#post-2467363)
 * Here is the index.php full code : [http://pastebin.com/q2wpQTqF](http://pastebin.com/q2wpQTqF)
 * And here is content.php : [http://pastebin.com/RkhsA3jx](http://pastebin.com/RkhsA3jx)
 * I already tried with all my plugins desactivated. Looks like they do not play
   a role in this issue.
 * With **default Twenty Eleven theme**, my condition works in `content.php`
    I’m
   looking at my code, trying to see anything different from Twenty Eleven default
   theme (as I mentioned, my own theme is based on this theme so it is very similar)
   which would break the `is_home()` condition…
 * Thanks for the kind help, I’m afraid I can’t paste the link to the website, it
   is not public yet.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/post-thumbnails-sizes/#post-2467365)
 * You have 5 loops on your index.php and you query the loop on all of them. If 
   it’s not the main loop (with pagination) it’s better to use the `$the_query =
   new WP_Query( $args );` method for these loops as this doesn’t interfere with
   the main query.
    [http://codex.wordpress.org/Function_Reference/WP_Query#Usage](http://codex.wordpress.org/Function_Reference/WP_Query#Usage)
 * Or on index.php use the global query_string on each query_posts and set is_home
   after each query_posts:
 *     ```
       global $query_string;
       query_posts("$query_string&tag=emplacement5");
       $wp_query->is_home = 1;
       ```
   

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Issue with is_home() condition on WP 3.3’ is closed to new replies.

## Tags

 * [has_tag()](https://wordpress.org/support/topic-tag/has_tag/)
 * [is_home](https://wordpress.org/support/topic-tag/is_home/)

 * 13 replies
 * 3 participants
 * Last reply from: [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * Last activity: [14 years, 5 months ago](https://wordpress.org/support/topic/post-thumbnails-sizes/#post-2467365)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
