is_home, and is_front_page conditional problem

Let’s see if I can confuse myself.

If either of your two OR conditions is true the code executes.

is_home and is_front_page can return true for different pages, negated in your case. If you have a static from page, which it sounds like you do, then is_home is the blog index page.

Note: WordPress 2.1 handles this function differently than prior
versions – See static Front Page. If you select a static Page as your
frontpage (see is_front_page()), this tag will be applied to your
“posts page”.

http://codex.wordpress.org/Function_Reference/is_home

What that means is that is_home will be false for every page except your blog index, which means that your !is_home conditional is true for every page except that blog index page and your code will run almost all the time.

Now the docs for is_front_page.

It returns TRUE when the main blog page is being displayed and the
Settings->Reading->Front page displays is set to “Your latest posts”,
or when is set to “A static page” and the “Front Page” value is the
current Page being displayed.

http://codex.wordpress.org/Function_Reference/is_front_page

There are two possibilities depending on your settings. It might return true for your blog index page, or it might return true for your static page. I think that you have a static front page so is_front_page will return true for that page and the !is_front_page conditional will be false. Because !is_home is (probably, if I am following you) true the code still executes.

If you want to exclude <p><?php the_time('F Y'); ?></p> from both the blog index and the static front page, then negate the entire OR statement:

if( !(is_home() || is_front_page()) )

If either is true then the whole thing is false.

If you want to exclude it only from the front page, then you shouldn’t need the !is_home part at all.

If you use && instead of || then both is_home and is_front_page would have to be false for the code to run. That is, you are not on the blog index and not on the front at the same time.

Leave a Comment