admin管理员组文章数量:1388146
I would like to query and sort posts by meta key "popularity" and these posts must have also another meta key "gone" with value "1" to query
$args = array(
'post_status' => 'publish',
'posts_per_page' => '150',
'cat' => $cat_id,
'order' => 'DESC'
'meta_query' => array(
'relation' => 'AND',
'popularity' => array(
'key' => 'popularity',
'orderby' => 'meta_value_num',
),
'be_price' => array(
'key' => 'gone',
'value' => '1'
)
)
);
I would like to query and sort posts by meta key "popularity" and these posts must have also another meta key "gone" with value "1" to query
$args = array(
'post_status' => 'publish',
'posts_per_page' => '150',
'cat' => $cat_id,
'order' => 'DESC'
'meta_query' => array(
'relation' => 'AND',
'popularity' => array(
'key' => 'popularity',
'orderby' => 'meta_value_num',
),
'be_price' => array(
'key' => 'gone',
'value' => '1'
)
)
);
Share
Improve this question
asked Oct 22, 2016 at 13:21
user97811user97811
1
2 Answers
Reset to default -1I am not sure what 'be_price'
is for, but I think your $args
should look like this:
$args = array(
'post_status' => 'publish',
'posts_per_page' => '150',
'cat' => $cat_id,
'meta_key' => 'popularity',
'order' => 'DESC',
'orderby' => 'meta_value_num',
'meta_query' => array(
'key' => 'gone',
'value' => '1'
)
);
$args = array(
'post_status' => 'publish',
'posts_per_page' => '150',
'cat' => $cat_id,
'order' => 'DESC',
'meta_query' => array(
'relation' => 'AND',
'popularity' => array(
'key' => 'popularity',
'orderby' => 'meta_value_num'
),
'gone' => array(
'key' => 'gone',
'value' => '1'
)
));
try this
本文标签: Query posts by meta value and sort by another meta key
版权声明:本文标题:Query posts by meta value and sort by another meta key 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744555758a2612463.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论