Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created October 15, 2012 21:13
Show Gist options
  • Save billerickson/3895534 to your computer and use it in GitHub Desktop.
Save billerickson/3895534 to your computer and use it in GitHub Desktop.
/**
* Limit homepage to one category
*
*/
function be_home_query( $query ) {
if( $query->is_main_query() && $query->is_home() && !is_admin() )
$query->set( 'category_name', 'sample-category' );
}
add_action( 'pre_get_posts', 'be_home_query' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment