admin管理员组文章数量:1334826
I'm not entirely sure how to word my question, but I'll give it a go.
Basically, what I'm wanting to do is order a group of posts by a custom field. I have a True/False custom field, created using the ACF plugin, which is displayed on a certain custom post type.
Right now, I've set up a query to firstly display posts with the True/False statement set to true, and then to display the posts with the statement set to false. This is working well.
What I want to do, however, is take the posts with the true statement and randomly change their order. All while keeping the current order or True first and then False in place.
Here is my current query.
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
// the query
$wpb_all_query = new WP_Query(
array('post_type'=>'businesses',
'post_status'=>'publish',
'category_name'=>basename(get_permalink()),
'meta_key'=>'featured',
'orderby'=>'meta_value',
'order'=>'DESC',
'posts_per_page'=>20,
'paged' => $paged)); ?>
<?php if ( $wpb_all_query->have_posts() ) : ?>
<!-- the loop -->
<?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?>
本文标签: wp queryWPQuery order by custom fieldthen randomly order some of results
版权声明:本文标题:wp query - WP_Query order by custom field, then randomly order some of results 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742228519a2436779.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论