Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Exclude Sensei lessons and courses from search results
<?php
// use the code below this comment
add_action( 'init', 'update_my_custom_type', 99 );
/**
* update_my_custom_type
*
* @author Joe Sexton <joe@webtipblog.com>
*/
function update_my_custom_type() {
global $wp_post_types;
if ( post_type_exists( 'lesson' ) ) {
// exclude from search results
$wp_post_types['lesson']->exclude_from_search = true;
}
if ( post_type_exists( 'course' ) ) {
// exclude from search results
$wp_post_types['course']->exclude_from_search = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment