Skip to content

Instantly share code, notes, and snippets.

@WebEndevSnippets
Forked from billerickson/functions.php
Created October 20, 2012 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WebEndevSnippets/3923224 to your computer and use it in GitHub Desktop.
Save WebEndevSnippets/3923224 to your computer and use it in GitHub Desktop.
WordPress: Limit Homepage to One Category
/**
* Limit homepage to one category
*
*/
function we_home_query( $query ) {
if( $query->is_main_query() && $query->is_home() && !is_admin() )
$query->set( 'category_name', 'sample-category' );
}
add_action( 'pre_get_posts', 'we_home_query' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment