$engine, // SWP Search Engine 's' => sanitize_text_field($args['s']), // search query 'fields' => 'ids', 'posts_per_page' => -1, // posts_per_page ) ); if ( ! empty( $swp_query->posts ) ) { $args['post__in'] = $swp_query->posts; // $swp_query->posts array $args['orderby'] = 'post__in'; // override orderby to relevance $args['s'] = ''; // Reset 's' term value } return $args; } } } /* * ALM_SearchWP * The main function responsible for returning the one true ALM_SearchWP Instance. * * @since 2.0.0 */ function ALM_SearchWP(){ global $alm_searchwp; if( !isset($alm_searchwp) ){ $alm_searchwp = new ALM_SearchWP(); } return $alm_searchwp; } ALM_SearchWP(); // initialize endif;