Last active
September 15, 2021 15:30
-
-
Save swissspidy/737f608f140b6034abd0d38539ac6eb5 to your computer and use it in GitHub Desktop.
Mini-plugin to force exclude Web Stories from the built-in WordPress search results
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 | |
/** | |
* Plugin Name: Web Stories Force Exclude From Search | |
* Description: Web Stories are by default excluded from the built-in WordPress search results. But some plugins might be interfering with that. This plugin tries to force-exclude stories again. | |
* Plugin URI: https://wp.stories.google/ | |
* Author: Pascal Birchler, Google | |
* Author URI: https://opensource.google.com/ | |
* Version: 0.0.2 | |
* License: Apache License 2.0 | |
* License URI: https://www.apache.org/licenses/LICENSE-2.0 | |
*/ | |
add_filter( | |
'register_post_type_args', | |
static function ( $args, $name ) { | |
if ( 'web-story' === $name ) { | |
$args['exclude_from_search'] = true; | |
} | |
return $args; | |
}, | |
10, | |
PHP_INT_MAX | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment