This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: re-use query sort order as search order with Ajax Search Pro.

Home Forums Product Support Forums Ajax Search Pro for WordPress Support re-use query sort order as search order with Ajax Search Pro. Reply To: re-use query sort order as search order with Ajax Search Pro.

#33620
Ernest MarcinkoErnest Marcinko
Keymaster

Great 🙂

The relevant fields in this case are these:

            'post_primary_order' => "relevance DESC", // CAN be a custom field name
            'post_secondary_order' => "post_date DESC",
            'post_primary_order_metatype'   => false, // false (if not meta), 'numeric', 'string'
            'post_secondary_order_metatype' => false, // false (if not meta), 'numeric', 'string'
            '_post_primary_order_metakey' => false,   // gets parsed later, do not touch
            '_post_secondary_order_metakey' => false, // gets parsed later  do not touch

The _post_primary_order_metakey and the _post_secondary_order_metakey are the meta field name, the field you mentioned is the meta type.
Also, when using the meta field ordering a sub query is created to join the meta field values to the main query in the main select. The select field name is “customfp” and “customfs”.

So when you set the post_primary_order_metatype and the _post_primary_order_metakey, then also use:
$args['post_primary_order'] = "customfp DESC";

..for the secondary:

$args['post_primary_order'] = "customfs DESC";