Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created October 30, 2011 00:09
Show Gist options
  • Save billerickson/1325276 to your computer and use it in GitHub Desktop.
Save billerickson/1325276 to your computer and use it in GitHub Desktop.
Don't show Events category on homepage
<?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