admin管理员组文章数量:1394093
I had a question that dont know why happen you use that query
$parent_args = array(
'post_type' => $parent_post_type_slug,
'meta_key' => $child_post_field_key,
'meta_value' => $user_field_value
);
$parent_posts = get_posts( $parent_args );
and work fine but if try to do this , the query return values that dont are correct
$parent_args = array(
'post_type' => $parent_post_type_slug,
'meta_query' => array(
array(
'key' => $child_post_field_key,
'value' => $user_field_value,
),
);
$parent_posts = get_posts( $parent_args );
I get a post that does not meet the condition
what am I doing wrong?
I had a question that dont know why happen you use that query
$parent_args = array(
'post_type' => $parent_post_type_slug,
'meta_key' => $child_post_field_key,
'meta_value' => $user_field_value
);
$parent_posts = get_posts( $parent_args );
and work fine but if try to do this , the query return values that dont are correct
$parent_args = array(
'post_type' => $parent_post_type_slug,
'meta_query' => array(
array(
'key' => $child_post_field_key,
'value' => $user_field_value,
),
);
$parent_posts = get_posts( $parent_args );
I get a post that does not meet the condition
what am I doing wrong?
Share Improve this question edited Mar 22, 2020 at 21:57 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Mar 21, 2020 at 17:34 Arucard7sArucard7s 11 bronze badge1 Answer
Reset to default 0The Answer is: Nothing. These two snippets SHOULD return the same posts.
However, there are a lot of things, that can change a query before it is executed: plugins, your own theme by a pre_get_posts Filter. So to check if it is an error in this code or some other code, you can disable all plugins, switch to a standard theme, and THEN test your snippet again.
本文标签: Question about of query
版权声明:本文标题:Question about of query 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744649500a2617599.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论