theme development - fetch all post from wp multisite network and sort all the post in descending order on the basis of &quot

fetch all post from wp multisite network and sort all the post in descending order on the basis of "Created by &quo

fetch all post from wp multisite network and sort all the post in descending order on the basis of "Created by " term

$all_blog = get_last_updated();
     $countpost = 1;
     foreach ($all_blog as $key=>$current_blog) {
            if($current_blog['blog_id'] != 1){    
                 switch_to_blog($current_blog['blog_id']);
            global $post;
$custom_query_args = array(
  'post_type'  => 'post',
  'meta_key'   => 'xyz',
  'meta_value' => 'yes',
  );

here I am getting sorted array of different sub domain.. but still I want to sort this

fetch all post from wp multisite network and sort all the post in descending order on the basis of "Created by " term

$all_blog = get_last_updated();
     $countpost = 1;
     foreach ($all_blog as $key=>$current_blog) {
            if($current_blog['blog_id'] != 1){    
                 switch_to_blog($current_blog['blog_id']);
            global $post;
$custom_query_args = array(
  'post_type'  => 'post',
  'meta_key'   => 'xyz',
  'meta_value' => 'yes',
  );

here I am getting sorted array of different sub domain.. but still I want to sort this

Share Improve this question edited Sep 20, 2019 at 5:17 Jacob Peattie 44.2k10 gold badges50 silver badges64 bronze badges asked Sep 20, 2019 at 3:40 Prem Kr GuptaPrem Kr Gupta 12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

So you first want to order them by author and then by date for every author?
You should use the orderby argument in your query, where you can pass an array.

$custom_query_args = array(
  'post_type'  => 'post',
  'meta_key'   => 'xyz',
  'meta_value' => 'yes',
  'orderby'    => array( 'author' => 'ASC', 'date' => 'DESC' )
  );

This should be something like what you want, otherwise look at the examples for the arguments in WP_Query.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745143783a4613552.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信