Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Last active October 4, 2019 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchristopher/840c7455338ae761bf9992ce1e3a22bd to your computer and use it in GitHub Desktop.
Save jchristopher/840c7455338ae761bf9992ce1e3a22bd to your computer and use it in GitHub Desktop.
Compatibility for AE Pro search results to prevent it from overriding SearchWP's results
<?php
// Compatibility for AE Pro search results to prevent it from overriding SearchWP's results.
add_filter( 'posts_pre_query', function( $posts, $wp_query ) {
if ( did_action( 'ae_pro_search' ) && $wp_query->is_search() ) {
$posts = array_keys( SWP()->results_weights );
$wp_query->found_posts = SWP()->foundPosts;
$wp_query->max_num_pages = SWP()->maxNumPages;
}
return $posts;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment