From 54c6bebaca1e4d72b76af447c177a4a745f86afd Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Mon, 23 May 2016 16:23:14 -0400 Subject: [PATCH] Function to only display posts of a certain category on the posts home page --- functions.php | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 * -- 2.17.1