From 43c63004afdcf46fa5cb7e006b0fbd2831666bdb Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Wed, 17 May 2017 16:57:45 -0400 Subject: [PATCH] Fixed the has-trail-product filter which was returning false too liberally, resulting in the Buy Map button not to display on most products --- functions.php | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/functions.php b/functions.php index 14dd004..0d604f6 100644 --- a/functions.php +++ b/functions.php @@ -272,30 +272,24 @@ add_filter('glm-get-trail-links', function($member_id) { }, 10, 2); add_filter('glm-has-trail-product', function($member_id) { - $products = get_posts( + wp_reset_query(); + $posts = get_posts( array( - 'post_status' => 'publish', - 'post_type' => 'product', + 'post_status' => 'publish', + 'post_type' => 'product', 'posts_per_page' => -1 -// 'meta_query' => array( -// array( -// 'key' => 'trail_id', -// 'value' => $member_id -// ) -// ) ) ); - foreach ($products as $product) { + foreach ($posts as $post) { // Explode the (hopefully) comma-separated list of member IDs into an array - $member_ids_for_product = explode(',', get_field( 'trail_id', $product->ID ) ); - + $member_ids_for_product = explode(',', get_field( 'trail_id', $post->ID ) ); + // If the current member is in the list of IDs if (in_array($member_id, $member_ids_for_product)) { return true; - } else { - return false; } } + return false; }); add_action('thematic_searchloop', 'mytheme_search_loop'); -- 2.17.1