Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created December 8, 2013 19:47
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/7862942 to your computer and use it in GitHub Desktop.
Save jchristopher/7862942 to your computer and use it in GitHub Desktop.
Limit SearchWP results to a single author
<?php
function searchwp_include_only_author( $ids, $engine, $terms ) {
$authorID = 8; // limit to author 8
// get the IDs of all the posts in this category
$args = array(
'author' => $authorID,
'fields' => 'ids'
);
$posts = new WP_Query( $args );
return $posts->posts;
}
add_filter( 'searchwp_include', 'searchwp_include_only_author', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment