From 58efaac7777f8e73c7a7c20775b2f92a434d3e8b Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Fri, 15 Feb 2019 18:19:12 -0500 Subject: [PATCH] Sidebar events widget pulls region ID from function now --- functions.php | 22 +++++++++++++++++++++- sections/county-page.php | 8 +------- sections/interior-page.php | 5 ----- sidebar.php | 10 +++------- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/functions.php b/functions.php index 1deadc1..fd81833 100644 --- a/functions.php +++ b/functions.php @@ -384,7 +384,27 @@ add_filter('events_search_widget', function(){ // 10, // 2 // ); - +function get_members_region_id() { + global $post; + $membersRegionId = false; + if ( !isset($GLOBALS['glmDetailSlug']) || !$GLOBALS['glmDetailSlug'] ) { + // If not on a member detail page, and a region id custom field exists, use that as the id + if ( function_exists("get_field") && get_field('members_region_id',$post->ID) ) { + // Check current page's custom field + $membersRegionId = get_field('members_region_id',$post->ID); + } else if ( function_exists("get_field") && get_field( 'members_region_id', wp_get_post_parent_id( $post ) ) ) { + // Check parent's custom field + $membersRegionId = get_field( 'members_region_id', wp_get_post_parent_id( $post ) ); + } else { + // If not on a member detail page, and no region id custom field exists, return events from all regions + $membersRegionId = false; + } + } else { + // If we're on a member detail page + $membersRegionId = apply_filters('get-current-memberinfo-field', 'region'); // returns null if no region found + } + return $membersRegionId; +} function get_county_page_id() { global $post; $countyPageId = false; diff --git a/sections/county-page.php b/sections/county-page.php index d0e7abe..7715352 100644 --- a/sections/county-page.php +++ b/sections/county-page.php @@ -8,13 +8,7 @@
Show More
- -
-
- ID); ?> -
-
- +
- - -
- -
diff --git a/sidebar.php b/sidebar.php index 8fa2c83..208a0f0 100644 --- a/sidebar.php +++ b/sidebar.php @@ -15,11 +15,7 @@ - + -- 2.17.1