• I’m working on a multisite using custom post types along with a custom field called listing_index. A user should be able to include a number in this field, allowing manual ordering of these custom post types, but my query appears to be ignoring it.

    $args = array(
                'post_type' => 'kodakalaris_listing',
                'posts_per_page' => 4,
                'orderby' => array(
                    'listing_index' => 'DESC',
                    'meta_value_num' => 'DESC'
                ),
                'meta_query' => array (
                    array (
                        'key' => 'listing_region_slug',
                        'value' => get_microsite_slug() . '-microsite-home-featured'
                    ),
                    array (
                        'key' => 'listing_index'
                    )
                )
            );

    Here’s the site

    Those numbers above each listing are their respective listing_index

Viewing 1 replies (of 1 total)
  • Thread Starter itsclarke

    (@itsclarke)

    $args = array(
                'post_type' => 'kodakalaris_listing',
                'posts_per_page' => 4,
                'orderby' => 'index_clause',
                'meta_query' => array (
                    'site_clause' => array (
                        'key' => 'listing_region_slug',
                        'value' => get_microsite_slug() . '-microsite-home-featured'
                    ),
                    'index_clause' => array (
                        'key' => 'listing_index',
                    )
                )
            );

    Ended up solving my problem. I found the solution here

Viewing 1 replies (of 1 total)

The topic ‘orderby not working in WP_Query’ is closed to new replies.