-
-
Save WebEndevSnippets/3923224 to your computer and use it in GitHub Desktop.
WordPress: Limit Homepage to One Category
This file contains 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
/** | |
* 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