From: Laury GvR Date: Mon, 23 May 2016 20:23:14 +0000 (-0400) Subject: Function to only display posts of a certain category on the posts home page X-Git-Tag: V1.2.2^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=54c6bebaca1e4d72b76af447c177a4a745f86afd;p=WP-Themes%2FGovernmentEmmet.git Function to only display posts of a certain category on the posts home page --- diff --git a/functions.php b/functions.php index adf378a..c4b6b22 100644 --- a/functions.php +++ b/functions.php @@ -118,6 +118,17 @@ function glm_get_header() { // echo ''; +/** + * This function will ensure only the posts from a certain category will display + * on the blog/post home page. + */ +function my_home_category( $query ) { + if ( $query->is_home() && $query->is_main_query() ) { + $query->set( 'cat', '29'); + } +} +add_action( 'pre_get_posts', 'my_home_category' ); + /** * glm_side_menu *