Support

Account

Home Forums Backend Issues (wp-admin) Filtering on custom field and sorting on another custom field Reply To: Filtering on custom field and sorting on another custom field

  • HI @ger-ang

    I think you can do something like:

    <?php
    $args = array ( 
        'numberposts'	=> -1,
        'post_type'		=> 'member',
        'post_status' => 'publish',	
        'meta_query' => array(
            'relation' => 'AND',
            'leadership_clause' => array(
                'key' => 'member_category',
                'value' => 'Leadership',
            ),
            'name_clause' => array(
                'key' => 'name_last_name',
                'compare' => 'EXISTS',
            ), 
        ),
        'orderby' => array( 
            'leadership_clause' => 'ASC',
            'name_clause' => 'ASC',
        ),
    );

    Code is untested!