Featured Articles

What to do if is_home() and is_archive() aren’t working in Wordpress ( How to fix )

It sometimes happens that the is_home() and is_archive() functions stop working in some Wordpress installs, so you can’t make use of them anymore. It has happened to me a few times and I’ve had a hard time replacing them with more complicated code. Fortunately, there’s one simple solution for this problem.

If calling is_home() or is_archive() doesn’t return the correct boolean value, then try using the wp_reset_query() Wordpress function before them.

Here’s an example:

<?php

wp_reset_query();

if(is_home()) echo’Welcome home!’;

?>

Please note this might also help if other functions stop working, like: is_category, in_category, is_tag, has_tag etc.

Let me know if this worked for you, because it works like charm for me on all my blogs.

Subscribe by RSS or enter your email for more News, Reviews and Tips & tricks:

Related Articles

This post was written by:

Alex Dumitru - who has written 643 posts on SoftSailor.


Contact the author

Leave a Reply to "What to do if is_home() and is_archive() aren’t working in Wordpress ( How to fix )"

Tags: , , , ,

Sign up for our FREE daily email newsletter


 

Latest Articles

Starcraft 2 Beta Key Wave 4 is a possibility, Dustin Browder interview
Starcraft 2 Beta Key Wave 4 is a possibility, Dustin Browder interview

Published on March 12 2010 5:30 AM PST

Like we reported last week, the Starcraft 2 Beta Key Wave 3 was designed to increase the number of players in each region of the [...]


Windows Phone 7 Series Requires 800×480, HTC HD2 Users Still Hoping
Windows Phone 7 Series Requires 800×480, HTC HD2 Users Still Hoping

Published on March 12 2010 5:09 AM PST

Microsoft announced the Windows Phone 7 Series and said that it will become the next generation mobile platform with incredible multimedia, gaming, and social media [...]


Apple Store Down: Apple Readying iPad Pre-order Page?
Apple Store Down: Apple Readying iPad Pre-order Page?

Published on March 12 2010 3:52 AM PST

At this very moment the Apple Store is down and there’s nothing you can do about it so you might as well play the plethora [...]


GDC 2010: Sony Confirms PlayStation Move Doesn’t Support 4 Players At Once
GDC 2010: Sony Confirms PlayStation Move Doesn’t Support 4 Players At Once

Published on March 12 2010 3:34 AM PST

Sony is running wild at the Game Developers Conference 2010 where it has unveiled their motion-controller called PlayStation Move. One big question that almost left [...]


Pre-order iPad As Of Today 8:30AM EST, Release Date Still April 3rd
Pre-order iPad As Of Today 8:30AM EST, Release Date Still April 3rd

Published on March 12 2010 2:42 AM PST

Apple did not officially release the iPad for pre-order, however, some folks are receiving news updates which say that pre-orders will begin today at 8:30AM [...]