Last active
October 28, 2016 01:24
-
-
Save chellestein/b08531ae1984971c3ac42fe1b1926ace to your computer and use it in GitHub Desktop.
WordPress Function to Exclude Categories from Front Page
This file contains 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 // | |
/** | |
* Do Not Include Above Opening PHP tag | |
* Copy/Paste Below code into functions file | |
* Replace the -1 to your unique category id number | |
* More than 1 category can be separated by a comma | |
*/ | |
//* Function to Remove categories | |
function exclude_category_home( $query ) { | |
if ( $query->is_home ) { | |
$query->set( 'cat', '-1' ); | |
} | |
return $query; | |
} | |
add_filter( 'pre_get_posts', 'exclude_category_home' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment