Created
January 26, 2018 14:37
-
-
Save djrmom/940a9c69eff8dc461051b9ee1ad8a42c to your computer and use it in GitHub Desktop.
limit post types on search page
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 | |
/* limit types searched on wp search page */ | |
add_action( 'pre_get_posts', function( $query ) { | |
if ( !is_admin() && $query->is_main_query() && $query->is_search() ) { | |
$query->set('post_type', 'post'); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment