Created
January 5, 2019 09:11
-
-
Save Tsunamijaan/74a01a95252292b392f9aa20823577ca to your computer and use it in GitHub Desktop.
Exclude Some Category from WP blog
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
| function exclude_category($query) { | |
| if ( $query->is_home() ) { | |
| $query->set('cat', '-xx'); | |
| } | |
| return $query; | |
| } | |
| add_filter('pre_get_posts', 'exclude_category'); | |
| Or add below line before start loop have_posts() ) : while ( have_posts()============= | |
| <?php $query = new WP_Query( 'cat=-3,-8' ); ?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment