[wp-trac] [WordPress Trac] #31231: WP_Query changes post_type on its own.
WordPress Trac
noreply at wordpress.org
Wed Feb 4 13:54:03 UTC 2015
#31231: WP_Query changes post_type on its own.
--------------------------+-----------------------------
Reporter: 23kulpamens | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.1
Severity: normal | Keywords:
Focuses: template |
--------------------------+-----------------------------
The code of the test )this is in bbpress -
bbpress/includes/topics/template.php:206:
{{{
var_dump($r);
$bbp->topic_query = new WP_Query( $r );
var_dump($bbp->topic_query);
}}}
And results of the test:
{{{
array(11) {
["post_type"]=>
string(5) "topic"
["post_parent"]=>
int(4514)
["meta_key"]=>
string(21) "_bbp_last_active_time"
["orderby"]=>
string(10) "meta_value"
["order"]=>
string(4) "DESC"
["posts_per_page"]=>
int(10)
["paged"]=>
int(1)
["s"]=>
bool(false)
["show_stickies"]=>
bool(true)
["max_num_pages"]=>
bool(false)
["perm"]=>
string(8) "readable"
}
object(WP_Query)#292 (46) {
["query_vars"]=>
array(65) {
["post_type"]=>
string(4) "post"
["post_parent"]=>
int(4514)
["meta_key"]=>
string(21) "_bbp_last_active_time"
["orderby"]=>
string(10) "meta_value"
["order"]=>
string(4) "DESC"
["posts_per_page"]=>
int(10)
["paged"]=>
int(1)
["s"]=>
bool(false)
["show_stickies"]=>
bool(true)
["max_num_pages"]=>
bool(false)
["perm"]=>
string(8) "readable"
["error"]=>
string(0) ""
["m"]=>
string(0) ""
["p"]=>
int(0)
["subpost"]=>
string(0) ""
["subpost_id"]=>
string(0) ""
["attachment"]=>
string(0) ""
["attachment_id"]=>
int(0)
["name"]=>
string(0) ""
["static"]=>
string(0) ""
["pagename"]=>
string(0) ""
["page_id"]=>
int(0)
["second"]=>
string(0) ""
["minute"]=>
string(0) ""
["hour"]=>
string(0) ""
["day"]=>
int(0)
["monthnum"]=>
int(0)
["year"]=>
int(0)
["w"]=>
int(0)
["category_name"]=>
string(0) ""
["tag"]=>
string(0) ""
["cat"]=>
string(0) ""
["tag_id"]=>
string(0) ""
["author"]=>
string(0) ""
["author_name"]=>
string(0) ""
["feed"]=>
string(0) ""
["tb"]=>
string(0) ""
["comments_popup"]=>
string(0) ""
["meta_value"]=>
string(0) ""
["preview"]=>
string(0) ""
["sentence"]=>
string(0) ""
["fields"]=>
string(0) ""
["menu_order"]=>
string(0) ""
["category__in"]=>
array(0) {
}
["category__not_in"]=>
array(0) {
}
["category__and"]=>
array(0) {
}
["post__in"]=>
array(0) {
}
["post__not_in"]=>
array(0) {
}
["tag__in"]=>
array(0) {
}
["tag__not_in"]=>
array(0) {
}
["tag__and"]=>
array(0) {
}
["tag_slug__in"]=>
array(0) {
}
["tag_slug__and"]=>
array(0) {
}
["post_parent__in"]=>
array(0) {
}
["post_parent__not_in"]=>
array(0) {
}
["author__in"]=>
array(0) {
}
["author__not_in"]=>
array(0) {
}
["ignore_sticky_posts"]=>
bool(false)
["suppress_filters"]=>
bool(false)
["cache_results"]=>
bool(true)
["update_post_term_cache"]=>
bool(true)
["update_post_meta_cache"]=>
bool(true)
["nopaging"]=>
bool(false)
["comments_per_page"]=>
string(2) "50"
["no_found_rows"]=>
bool(false)
}
["tax_query"]=>
object(WP_Tax_Query)#3710 (6) {
["queries"]=>
array(0) {
}
["relation"]=>
string(3) "AND"
["table_aliases:protected"]=>
array(0) {
}
["queried_terms"]=>
array(0) {
}
["primary_table"]=>
string(8) "wp_posts"
["primary_id_column"]=>
string(2) "ID"
}
["meta_query"]=>
object(WP_Meta_Query)#3706 (7) {
["queries"]=>
array(2) {
[0]=>
array(1) {
["key"]=>
string(21) "_bbp_last_active_time"
}
["relation"]=>
string(2) "OR"
}
["relation"]=>
string(3) "AND"
["meta_table"]=>
string(11) "wp_postmeta"
["meta_id_column"]=>
string(7) "post_id"
["primary_table"]=>
string(8) "wp_posts"
["primary_id_column"]=>
string(2) "ID"
["table_aliases:protected"]=>
array(1) {
[0]=>
string(11) "wp_postmeta"
}
}
["date_query"]=>
bool(false)
["post_count"]=>
int(0)
["current_post"]=>
int(-1)
["in_the_loop"]=>
bool(false)
["comment_count"]=>
int(0)
["current_comment"]=>
int(-1)
["found_posts"]=>
int(0)
["max_num_pages"]=>
int(0)
["max_num_comment_pages"]=>
int(0)
["is_single"]=>
bool(false)
["is_preview"]=>
bool(false)
["is_page"]=>
bool(false)
["is_archive"]=>
bool(true)
["is_date"]=>
bool(false)
["is_year"]=>
bool(false)
["is_month"]=>
bool(false)
["is_day"]=>
bool(false)
["is_time"]=>
bool(false)
["is_author"]=>
bool(false)
["is_category"]=>
bool(false)
["is_tag"]=>
bool(false)
["is_tax"]=>
bool(false)
["is_search"]=>
bool(true)
["is_feed"]=>
bool(false)
["is_comment_feed"]=>
bool(false)
["is_trackback"]=>
bool(false)
["is_home"]=>
bool(false)
["is_404"]=>
bool(false)
["is_comments_popup"]=>
bool(false)
["is_paged"]=>
bool(false)
["is_admin"]=>
bool(false)
["is_attachment"]=>
bool(false)
["is_singular"]=>
bool(false)
["is_robots"]=>
bool(false)
["is_posts_page"]=>
bool(false)
["is_post_type_archive"]=>
bool(true)
["query_vars_hash:private"]=>
string(32) "40130020a8a2a2f88b4b44834d315300"
["query_vars_changed:private"]=>
bool(true)
["thumbnails_cached"]=>
bool(false)
["stopwords:private"]=>
NULL
["query"]=>
array(11) {
["post_type"]=>
string(5) "topic"
["post_parent"]=>
int(4514)
["meta_key"]=>
string(21) "_bbp_last_active_time"
["orderby"]=>
string(10) "meta_value"
["order"]=>
string(4) "DESC"
["posts_per_page"]=>
int(10)
["paged"]=>
int(1)
["s"]=>
bool(false)
["show_stickies"]=>
bool(true)
["max_num_pages"]=>
bool(false)
["perm"]=>
string(8) "readable"
}
["request"]=>
string(467) "SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts
INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1
AND wp_posts.post_parent = 4514 AND wp_posts.post_type = 'post' AND
(wp_posts.post_status = 'publish' OR wp_posts.post_status = 'closed' OR
wp_posts.post_status = 'private' OR wp_posts.post_status = 'hidden') AND (
wp_postmeta.meta_key = '_bbp_last_active_time'
) GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value DESC LIMIT 0, 10"
["posts"]=>
array(0) {
}
}
}}}
As you can se the post_type had been changed form "topic" to "post". It is
right in the WP_Query->query field, but it looks like WP_Query->query_vars
is more important. It is also the reason why bbpress want to work in my
case.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31231>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list