Order by user_status, meta_value, date
-
I am building a site where user can submit a profile (which is basically an ad).
The lists need to be ordered by 3 parameters:
1) by user_status (if user has a certain capability)
2) by a meta_value from a custom (ACF) field
3) by (published) date2 and 3 is not a problem, but I can’t find how to get the user status in there as well. I don’t want to query just those users with that certain cap, I just want to use it to order it so users who have that cap end up higher in the lists/results.
This is what I have so far:
public static function get_profiles( $amount = 24, $exclude = array(), $taxonomy = false, $author = false, $post_status = 'publish', $offset = 0 ) { if ( $taxonomy ) { $tax_query = array( array( 'taxonomy' => Taxonomies::SEX, 'field' => 'slug', 'terms' => $taxonomy, ) ); } else { $tax_query = false; } $profile_posts = get_posts(array( 'post_type' => PostTypes::PROFILE, 'post_status' => $post_status, 'posts_per_page' => $amount, 'meta_key' => 'sd_move_item_up_timestamp', 'tax_query' => $tax_query, 'author' => $author, 'exclude' => $exclude, 'offset' => $offset, 'orderby' => array( 'meta_value_num' => 'DESC', 'date' => 'DESC' ), 'suppress_filters' => false, )); return $profile_posts; }
The order by parameter should be something like this:
array( 'vip_status' => 'DESC', 'meta_value_num' => 'DESC', 'date' => 'DESC' ),
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Order by user_status, meta_value, date’ is closed to new replies.