From c9b9542137bb196dc8667c21610cc5cd35090c59 Mon Sep 17 00:00:00 2001 From: Markus Ankenbrand Date: Mon, 12 Sep 2016 19:37:08 +0200 Subject: [PATCH] Add function to filter posts on start page by category --- functions.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/functions.php b/functions.php index cadbf37..6ad43ce 100644 --- a/functions.php +++ b/functions.php @@ -20,6 +20,14 @@ function my_acf_google_map_api( $api ){ add_filter('acf/fields/google_map/api', 'my_acf_google_map_api'); +// Only show posts of category Urlaub (id=2) +function my_home_category( $query ) { + if ( $query->is_home() && $query->is_main_query() ) { + $query->set( 'cat', '2'); + } +} + +add_action( 'pre_get_posts', 'my_home_category' ); // Related posts function function atravelblog_related_posts() {