Add function to filter posts on start page by category

This commit is contained in:
Markus Ankenbrand 2016-09-12 19:37:08 +02:00
parent bf7be82f70
commit c9b9542137

View file

@ -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() {