Created
December 8, 2013 19:47
-
-
Save jchristopher/7862942 to your computer and use it in GitHub Desktop.
Limit SearchWP results to a single author
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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