We help IT Professionals succeed at work.

Wordpress, PHP is_home() function not working?

mellijae asked
I have some text and code in my footer, and I only want to display it on my homepage. So I inserted this--

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

With the closing PHP tag after the homepage-only content.

It is not working the way I anticipated:

* The content within the tag is NOT displayed on the homepage, which is bad.
* It's also not displayed on blog posts or pages, which is great.
* The content IS DISPLAYED on archive pages ONLY, it seems, which is bad. (Category pages, etc.)

I would really, really appreciate the help. Thank you in advance!

The site is at http://www.sdslawaz.com
Watch Question

Replace is_home condition with if( $wp->query_vars['pagename'] == 'home' ) and see if the content is displayed.

Or you can use <?php if(is_home() || is_front_page()) echo 'match'; ?>

Have you selected any template page as home page?


Thank you for answering atique_ansari

The first code is implemented right now at sdslawaz.com

This makes the content disappear everywhere. So we are getting closer! Just need to get it to appear on the homepage now!

The second line of code you gave me just caused a php error message on that line.

I don't understand your question though. My homepage is a Wordpress page, in the Thesis theme, called "Home." I am sorry that I don't understand.

atique_ansari had the right idea


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


<?php if ( is_home() || is_front_page() ) { ?>
Are you using any template page as home page? I mean have you selected any page to be displayed as home page from wp-admin?


It turned out to be a theme specific problem to Thesis...