Wednesday, December 14, 2022
HomeWordPress Developmentcustomization - Consumer Question A number of Orderby Clause

customization – Consumer Question A number of Orderby Clause


I am having bother getting constant outcomes from a WP_User_Query when ordering by a number of meta values.

There’s a meta discipline that accommodates a serialized listing of IDs, and I have to show customers with a sure ID (72) first. These customers should be alphabetized by final identify. The next customers with out this ID should be alphabetized by final identify as effectively.

The question works effective if I solely search for customers with the ID 72 and type by final identify. Once I use the question beneath nevertheless, I get inconsistent final identify sorting outcomes. The ID 72 customers at all times present up first, however sure customers are inexplicably out of order.

Here is the gist of my question:

$customers = new WP_User_Query( array(
    'meta_query' => array(
        'relation' => 'AND',
        'lastname' => array(
            'key' => 'last_name',
            'evaluate' => 'EXISTS',
            'sort' => 'CHAR',
        ),
        'listing' => array(
            'distribution_list' => array(
                'key' => 'distribution_list',
                'worth' => '"72"',
                'evaluate' => 'LIKE'
            ),
            'distribution_list2' => array(
                'key' => 'distribution_list',
                'worth' => '"72"',
                'evaluate' => 'NOT LIKE'
            ),
            'relation' => 'OR',
        ),
        'orderby' => array(
            'distribution_list' => 'ASC',
            'last_name' => 'ASC',
        ),
    )
) );

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments