Home Forums General Issues Sort Query by Unrelated Custom Field


Sort Query by Unrelated Custom Field

  • I have searched and read the WP documentation, but I just can’t seem to wrap my head around how to accomplish this. I have a query based on one custom field team_member_type, and it outputs all the people and I have it separated into sections based on the type of team member they are… but I want it to then sort each of those sections by the persons last name, which I have setup in a custom field team_member_last_name.

    I’m not using meta_query because I don’t want to associate the two custom fields with AND or OR cause that’s unrelated to pulling my query. I only need the last name field to orderby.

    $args = array(
    	'posts_per_page' => -1,
    	'post_type' => 'team-member',
    	'meta_key' => 'team_member_type',
    	'meta_value' => array(
    				'Scientist or Technical',
    	'orderby' => 'title',
    	'order' => 'ASC'
    $the_query = new WP_Query( $args );
  • Hi @hube2, yes your other response made it easier since I was able to use two queries. Thanks again.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Sort Query by Unrelated Custom Field’ is closed to new replies.