Last active
December 3, 2016 09:13
-
-
Save aldolat/1b32333bc003bc6586b0bafcf4dd2afd to your computer and use it in GitHub Desktop.
Hide posts from a certain category in the main query.
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 | |
| /** | |
| * Change the main query in order to hide posts from certain categories. | |
| * | |
| * @see https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts | |
| */ | |
| function my_customized_query( $query ) { | |
| if ( $query->is_home() && $query->is_main_query() ) { | |
| $query->set( 'cat', '-10,-11,-325' ); | |
| } | |
| } | |
| add_action( 'pre_get_posts', 'my_customized_query' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment