Im using Listify Theme with WP Job Manager Paid Listings. Now I need to sort the Listings with the Subscription Level (I have Platinum, Gold, and Silver). I am currently modifying the plugin's code but still don't work. I need to know if it is possible to sort the Listings using their _package_id meta value that will connect to the ID of Products(Subscription) post type (Woocommerce).

This is my current custom arguments for Listings:

function xyz_custom_orderby_query_args( $query_args ) {

            $args = array(
                    // Type & Status Parameters
                'post_type'   => 'products',    

                    // Order & Orderby Parameters
                'order'               => 'DESC',
                'orderby'             => 'meta_value',
                    // Pagination Parameters
                'posts_per_page'         => -1,
                    // Custom Field Parameters
                'meta_key'       => '_priority',
                'meta_value'     => 'value',
                'meta_compare'   => 'EXISTS',
            );

            $query = new WP_Query( $args );


            $query_args['meta_query'] =  array(
                'relation' => 'AND',
                'query_one' => array(
                    'key' => '_package_id',
                     'compare' => 'EXISTS', // Optional
                 ),
                'query_two' => array(
                    'key' => '_average_rating',
                ),
            );
            $query_args['orderby'] = array(
                'query_one' => 'DESC', // sort by numerical custom field  
                'query_two' => 'DESC', // sort by numerical custom field           
                'title' => 'ASC',

            );


            return $query_args;
        }

        add_filter( 'get_job_listings_query_args', 'xyz_custom_orderby_query_args', 99 );

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.