Skip to content

Instantly share code, notes, and snippets.

@jamiemitchell
Forked from billerickson/gist:1325276
Created February 8, 2013 00:33
Show Gist options
  • Save jamiemitchell/4735559 to your computer and use it in GitHub Desktop.
Save jamiemitchell/4735559 to your computer and use it in GitHub Desktop.
<?php
/**
* Don't show Events category on homepage
* Category 5 = Events category, so we use cat=-5
*
* @link http://www.billerickson.net/thesis-wordpress-remove-category-homepage/
* @author Bill Erickson
* @param object $query
*/
function be_exclude_events_from_home( $query ) {
if( $query->is_main_query() && !is_admin() && $query->is_home() )
$query->set( 'cat', '-5' );
}
add_action( 'pre_get_posts', 'be_exclude_events_from_home' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment