admin管理员组文章数量:1326447
This is my code :
print_r($args)
//Output
array(6) { ["post_type"] => string(9) "order"
["date_query"] => array(2) {
["before"] => string(3) "now"
["compare"] => string(1) "="
}
["post_status"] => string(9) "validated"
["posts_per_page"] => int(-1)
["orderby"] => string(5) "title"
["order"] => string(3) "ASC"
}
And this is the request :
$wp_query = new \WP_Query( $args );
var_dump( $wp_query->request );
//Output
"SELECT wp_posts.*
FROM wp_posts
WHERE 1=1
AND ( wp_posts.post_date < '2020-08-07 16:46:27' )
AND wp_posts.post_name = 'asc'
AND wp_posts.post_type = 'order'
AND ((wp_posts.post_status = 'validated'))
ORDER BY wp_posts.post_title ASC "
So WP_Query in the query says wp_posts.post_name = 'asc'
!!!
Why ?
This is my code :
print_r($args)
//Output
array(6) { ["post_type"] => string(9) "order"
["date_query"] => array(2) {
["before"] => string(3) "now"
["compare"] => string(1) "="
}
["post_status"] => string(9) "validated"
["posts_per_page"] => int(-1)
["orderby"] => string(5) "title"
["order"] => string(3) "ASC"
}
And this is the request :
$wp_query = new \WP_Query( $args );
var_dump( $wp_query->request );
//Output
"SELECT wp_posts.*
FROM wp_posts
WHERE 1=1
AND ( wp_posts.post_date < '2020-08-07 16:46:27' )
AND wp_posts.post_name = 'asc'
AND wp_posts.post_type = 'order'
AND ((wp_posts.post_status = 'validated'))
ORDER BY wp_posts.post_title ASC "
So WP_Query in the query says wp_posts.post_name = 'asc'
!!!
Why ?
Share Improve this question edited Aug 7, 2020 at 15:13 mozboz 2,6281 gold badge12 silver badges23 bronze badges asked Aug 7, 2020 at 14:54 J.BizMaiJ.BizMai 9002 gold badges10 silver badges30 bronze badges1 Answer
Reset to default 0The reason is :
My custom post type is "order"
So $args['post_type'] = "order"
And $args['order'] = "asc"
And for some reason WP_Query
made wp_posts.post_name = 'asc'
I fixed this adding a prefix for my custom post type name like
foo-order
so$args['post_type'] = "foo-order"
本文标签: wp queryWPquery has incorrect wppostspostname39asc39 when I have custom post type called 39order39
版权声明:本文标题:wp query - WP_query has incorrect wp_posts.post_name = 'asc' when I have custom post type called 'order& 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742205040a2432658.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论