Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mini-plugin to exclude Web Stories from the built-in WordPress search results
<?php
/**
* Plugin Name: Web Stories Exclude From Search
* Description: Exclude Web Stories from the built-in WordPress search results.
* Plugin URI: https://wp.stories.google/
* Author: Pascal Birchler, Google
* Author URI: https://opensource.google.com/
* Version: 0.0.1
* 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,
2
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment