Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created January 22, 2015 14:14
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/de7bf85297c2e2ec0878 to your computer and use it in GitHub Desktop.
Save jchristopher/de7bf85297c2e2ec0878 to your computer and use it in GitHub Desktop.
Filter the array of results returned by SearchWP
<?php
function my_searchwp_results( $results, $attributes ) {
// available $attributes are:
//
// $attributes['terms'] the search terms
// $attributes['page'] the current page
// $attributes['order'] the results order
// $attributes['foundPosts'] the number of found posts
// $attributes['maxNumPages'] the total number of pages of results
// $attributes['engine'] the engine in use
// modify $results in any way you'd like
return $results;
}
add_filter( 'searchwp_results', 'my_searchwp_results', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment