Created
March 18, 2015 20:28
-
-
Save markjaquith/1d1c5f7e0ff502928e89 to your computer and use it in GitHub Desktop.
exclude post type from search
This file contains hidden or 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 | |
add_action( 'parse_query', 'gws_exclude_from_search' ); | |
function gws_exclude_from_search( $q ) { | |
$exclude_from_search = array( 'gallery-entries' ); | |
if ( $q->is_search ) { | |
foreach ( $exclude_from_search as $post_type ) { | |
$post_type_object = get_post_type_object( $post_type ); | |
$post_type_object->exclude_from_search = true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment