From 63f784acf5d9595e3743f256b7166a8e45ba0253 Mon Sep 17 00:00:00 2001 From: Markus Ankenbrand Date: Mon, 12 Sep 2016 13:38:27 +0200 Subject: [PATCH] Add code to display Touren for each Urlaub --- functions.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/functions.php b/functions.php index 331977a..4483030 100644 --- a/functions.php +++ b/functions.php @@ -71,6 +71,28 @@ function atravelblog_related_posts() { echo(' '); endif; wp_reset_query(); + $touren = new WP_Query( array( + 'category_name' => 'Tour', + 'posts_per_page' => -1, + 'meta_query' => array( + array( + 'key' => 'urlaub', // name of custom field + 'value' => get_the_ID(), // matches exaclty "123", not just 123. This prevents a match for "1234" + 'compare' => '=' + ) + ) + ) ); + if ($touren->have_posts()) : + echo('

Touren:

'); + echo(' '); + endif; + wp_reset_query(); } elseif($cat == 'Tour') { $urlaub = new WP_Query(array('p' => get_field('urlaub')[0])); if ($urlaub->have_posts()) :