WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My front page is just a list of the posts separated by category. I'm working on a plugin that get the id of the post but needs to test if the user is currently on the front page:

     do this thing
else {
     do this other thing

problem is, on the post pages it returns true for is_front_page. I tried is_home but get the same result.

I have the home in admin set to "latest posts" (not a static page) and displaying the posts on the main page via loop-home. I'm using is_home in the header and getting the correct response.

share|improve this question

closed as off-topic by s_ha_dum, Chip Bennett, toscho Oct 21 '13 at 17:41

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?" – s_ha_dum, Chip Bennett, toscho
If this question can be reworded to fit the rules in the help center, please edit the question.

Please post your full code in context; include your settings -> reading for "front page displays", "front page", and "posts page"; and indicate what template is being used to render the site front page. – Chip Bennett Oct 21 '13 at 16:56
There really isn't any code to post right now as I'm just testing before I dive deeper. As stated, under the settings "Latest Posts" is selected as the front page (default), loop-home.php displays those posts, and post pages use single.php. – dcp3450 Oct 21 '13 at 17:00
up vote 0 down vote accepted

Turns out since the plugin output in the footer I just had to reset the query: wp_reset_query();

share|improve this answer
If you need to reset the query, I'll guess you're using query_posts somewhere, which is not recommended. – Milo Oct 21 '13 at 17:37
Good point. Some of the code for this site was written when I was still a bit green. If I have the time I'll circle back and see where that piece is. Thanks for the heads up. – dcp3450 Oct 25 '13 at 15:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.