Last active
April 5, 2020 04:18
-
-
Save LeanSeverino1022/db4434543a96b1f7bc6d2d6470867a17 to your computer and use it in GitHub Desktop.
[Exclude Category from Blog] #wordpress
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
/** | |
* Exclude Category from Blog | |
* | |
* @author Bill Erickson | |
* @link https://www.billerickson.net/customize-the-wordpress-query/ | |
* @param object $query data | |
* | |
*/ | |
function be_exclude_category_from_blog( $query ) { | |
if( $query->is_main_query() && ! is_admin() && $query->is_home() ) { | |
$query->set( 'cat', '-4' ); | |
} | |
} | |
add_action( 'pre_get_posts', 'be_exclude_category_from_blog' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment