0

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.