741 posts
  • Has been a member for 5-6 years
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Most Wanted Bounty Winner
  • Bought between 50 and 99 items
  • Poland
  • Referred between 10 and 49 users
Orbital_Themes says

So… I have a conditional statement in my sidebar.php that goes like this: if( is_home() ), everyone’s familiar with it, right?

Please tell me guys, why the hell it works well on pages with default page template, but when I choose “Blog” (my custom) page template, the conditional statement returns true :O

I will appreciate any help as I’m struggling with this for some time now :)

1475 posts The right tools with none of the gimmicks
  • Sold between 50 000 and 100 000 dollars
  • Elite Author
  • Has been a member for 4-5 years
  • Referred between 50 and 99 users
  • Bought between 10 and 49 items
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
  • United States
+1 more
PixelBin says

Did you so happen to choose that page as your static home page? ;)

741 posts
  • Has been a member for 5-6 years
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Most Wanted Bounty Winner
  • Bought between 50 and 99 items
  • Poland
  • Referred between 10 and 49 users
Orbital_Themes says
Did you so happen to choose that page as your static home page? ;)

Heh nope ;p when I change the template to default everything works as it should. The same happens for every other pages.

76 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • New Zealand
  • Sold between 1 000 and 5 000 dollars
duane_ashworth says

i believe that when you change your homepage to a static one wordpress uses the index.php or home.php to provide the template for that page rather than the one you include in your pages properties.

Maybe make sure that the conditional appears in one of these pages to make it work.

374 posts
  • Bought between 10 and 49 items
  • Contributed a Blog Post
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
_rohan says

is_home() returns true on your posts page. This could mean:

1. Homepage when Settings>Reading says ‘Show my latest posts’

2. Blog page when Settings>Reading uses a static homepage and the same blog page for latest posts.

741 posts
  • Has been a member for 5-6 years
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Most Wanted Bounty Winner
  • Bought between 50 and 99 items
  • Poland
  • Referred between 10 and 49 users
Orbital_Themes says

My Settings>Reading “Front page displays” is set to “Your latest posts”. I use a custom page template with custom query that queries posts with post type of blog. No matter which page (be it a about, contact or blog) I set to “Blog” page template, the is_home() returns true. I will try and create any other page template and see what happens then.

Any more ideas?

UPDATE :

When I delete custom query from my blog.php file everything goes back to normal, but then why would I need a blog page template without posts on it? And why the f* would custom query make a difference while checking for homepage?? :|

436 posts Don't be a HATER!
  • Exclusive Author
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Has been a member for 4-5 years
webinpixels says
try to reset your query post mate

//custom query here

wp_reset_query(); //reset the query

hope this help :)

741 posts
  • Has been a member for 5-6 years
  • Sold between 50 000 and 100 000 dollars
  • Exclusive Author
  • Most Wanted Bounty Winner
  • Bought between 50 and 99 items
  • Poland
  • Referred between 10 and 49 users
Orbital_Themes says
try to reset your query post mate

//custom query here

wp_reset_query(); //reset the query
hope this help :)

You rock mate…!!! Thanks a lot! Worked like a charm :D

by
by
by
by
by
by