Available since: 1.3
searchwp_prevent_indexing
Note: Use of this hook will require a manual reindex
If you would like to ensure that certain posts are completely ignored both when indexing and searching, this filter allows you to do just that.
Example: To prevent certain posts from being indexed and searched, add the following to your active theme’s functions.php
:
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 my_searchwp_prevent_indexing() { | |
$post_ids = array( 15, 90 ); // EXCLUDE posts 15 and 90 from the index and searches | |
return $post_ids; | |
} | |
add_filter( 'searchwp_prevent_indexing', 'my_searchwp_prevent_indexing' ); |