2

I'm having an odd issue, although I can understand why it works like this I do need to find a way around it.

I have used the the request filter to modify the query for the home/index page to select for a post type other than 'post'

The result of this is that is_home() is returning false in the index.php template. If I disable the filter then is_home() goes back to returning true.

Anyway to force the is_home() to return true? or another way to approach this?

Thanks, Stewart.

4
  • Is this related? When to use is_home() vs is_front_page()?
    – brasofilo
    Commented Jun 13, 2012 at 10:43
  • @brasofilo unfortunately no. I haven't changed the page that is acting as the home or the front page within the Admin Panel, I have just modified the query it uses. Therefore in this case both is_home() and is_front_page() should return true but neither do.
    – Stewarty
    Commented Jun 13, 2012 at 10:53
  • I see... so, it'd be better if you published your code...
    – brasofilo
    Commented Jun 13, 2012 at 10:56
  • Please provide us with at least the function and the filter you are using.
    – Brooke.
    Commented Sep 20, 2012 at 6:45

1 Answer 1

0

From look at the code the following logic happens in your case:

  • query is for one post type that has archive
  • is_post_type_archive gets set to true
  • is_archive gets set to true
  • is_home gets set to false since it is seen as archive

I am not sure about all implications without extensive testing, but probably approaches are either:

  1. artificially set is_home to true under those circumstances
  2. ignore failing is_home() and use different conditional

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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