Created
June 22, 2014 16:44
-
-
Save ovizii/ea32b0044da927c31926 to your computer and use it in GitHub Desktop.
Restrict home page posts to certain categories
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 my_home_category( $query ) { | |
if ( $query->is_home() && $query->is_main_query() ) { | |
$query->set( 'cat', '11'); | |
} | |
} | |
add_action( 'pre_get_posts', 'my_home_category' ); | |
//If you would like to include more than one category, then just add another ID by inserting a comma and the ID number. For example, this is will display category 11 and category 14. | |
//$query->set( 'cat', ’11, 14’ ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment