Return to Snippet

Revision: 67354
at September 13, 2014 10:05 by chrisaiv


Initial Code
/**
* Selective posts
*
* http://premium.wpmudev.org/blog/one-category-wordpress-homepage/
*/

function my_home_category( $query ) {

 if ( $query->is_home() && $query->is_main_query() ) {

 //Category 32 is Frontpage
 $query->set( 'cat', '32');
 }
}
add_action( 'pre_get_posts', 'my_home_category' );

Initial URL
http://premium.wpmudev.org/blog/one-category-wordpress-homepage/

Initial Description
If you’d like to show posts from only one category on your homepage, then it’s easy enough to do.

Initial Title
Wordpress: Show posts from only one category

Initial Tags
wordpress

Initial Language
JavaScript