php - Wordpress is_home() function returns false positive for multiple post-type query -
i struggle me seems logic flaw wordpress whether or not is, need solution. had modify current setup , change queries include 2 post types instead of one.
now query works fine, lot of functionality lacks because is_home() returns 1 instead of 0 on archive page. according documentation, function should 1 on blogs page
* if static page set front page of site, function return true * on page set "posts page".
as matter of fact, returns true
although in different archive 'posts page' (which blog). if query of archive holds 1 post_type, is_home()
returns 0. if add post type query (which necessary me) is_home()
returns true
.
the problem within query.php
file in wordpress core. is_home()
returns true if, among others, is_archive
within query object false
. is_archive
in case should true (which not). is_archive
true if is_post_type_archive
true (which not).
and thats problem lays: is_post_type_archive
set true wordpress if
1) post_type not array, and
2) post_type objects value has_archive
query true
both conditions don't apply me since 1) post_type array, , therefore expect 2) there not 1 post type object array of post types , therefore has_archive cannot true.
long story short: have archive page posts different post_types , work, these items not blog page , therefore, according docs, is_home should still false.
two questions: 1) expected behavior of is_home()? , 2) there function substitue function , work multiple-post-type-query? (if not, suggestions on how achieve that?)
thanks in advance ideas.
for record (if stumbles upon thread similar issue): worked around checking get_post_type() == 'post'
instead of is_home()
- still not satisfying. docs is_home() result in true on posts page , not.
Comments
Post a Comment