17. Wertungslauf des Elbe-Ohre-Cups
20. Sudenburglauf 2023
datum
Bereich | Name | Telefon |
---|
'event-type', 'fields' => 'ids', // Only get term IDs to avoid unnecessary data 'hide_empty' => false // Include terms even if they are not assigned to any posts ]); return $terms; // Return all event-type term IDs } // Otherwise, filter by region logic if (!empty($region_events)) { foreach ($region_events as $index => $region_event) { $matched = false; if (!empty($bundesland) && !empty($region_event['bundesland'])) { foreach ($region_event['bundesland'] as $term) { if ($term->slug === $bundesland) { $matched = true; break; } } } if (!$matched && !empty($kreis) && !empty($region_event['kreis'])) { foreach ($region_event['kreis'] as $term) { if ($term->slug === $kreis) { $matched = true; break; } } } if (!$matched && !empty($stadt) && !empty($region_event['stadt'])) { foreach ($region_event['stadt'] as $term) { if ($term->slug === $stadt) { $matched = true; break; } } } if ($matched && !empty($region_event['kind_of_event'])) { $event_types = array_merge($event_types, $region_event['kind_of_event']); } } } // Return collected event types or default to homepage events return empty($event_types) ? $home_events : $event_types; } function build_tax_query($bundesland, $kreis, $stadt, $plz_ort, $sportart) { $tax_query = ['relation' => 'AND']; if (!empty($bundesland)) { $tax_query[] = [ 'taxonomy' => 'bundesland', 'field' => 'slug', 'terms' => $bundesland, ]; } if (!empty($kreis)) { $tax_query[] = [ 'taxonomy' => 'kreis', 'field' => 'slug', 'terms' => $kreis, ]; } if (!empty($stadt)) { $tax_query[] = [ 'taxonomy' => 'stadt', 'field' => 'slug', 'terms' => $stadt, ]; } if (!empty($plz_ort)) { $tax_query[] = [ 'taxonomy' => 'plz-ort', 'field' => 'slug', 'terms' => $plz_ort, ]; } if (!empty($sportart)) { $tax_query[] = [ 'taxonomy' => 'sportart', 'field' => 'slug', 'terms' => $sportart, ]; } return $tax_query; } add_filter('tribe_events_views_v2_view_repository_args', function ($args) { if (is_admin() || !is_array($args)) { return $args; } $bundesland = isset($_GET['bl']) ? sanitize_text_field($_GET['bl']) : ''; $kreis = isset($_GET['kr']) ? sanitize_text_field($_GET['kr']) : ''; $stadt = isset($_GET['st']) ? sanitize_text_field($_GET['st']) : ''; $plz_ort = isset($_GET['zip']) ? sanitize_text_field($_GET['zip']) : ''; $sportart = isset($_GET['sp']) ? sanitize_text_field($_GET['sp']) : ''; $event_types = get_filtered_region_event_types($bundesland, $kreis, $stadt, $plz_ort); $args['tax_query'] = build_tax_query($bundesland, $kreis, $stadt, $plz_ort, $sportart); if (!empty($event_types)) { $args['tax_query'][] = [ 'taxonomy' => 'event-type', 'field' => 'term_id', 'terms' => $event_types, ]; } return $args; }); add_filter('generateblocks_query_loop_args', function ($query_args, $attributes) { if (is_admin() || empty($attributes['className']) || strpos($attributes['className'], 'newsfilter') === false) { return $query_args; } $bundesland = isset($_GET['bl']) ? sanitize_text_field($_GET['bl']) : ''; $kreis = isset($_GET['kr']) ? sanitize_text_field($_GET['kr']) : ''; $stadt = isset($_GET['st']) ? sanitize_text_field($_GET['st']) : ''; $plz_ort = isset($_GET['zip']) ? sanitize_text_field($_GET['zip']) : ''; $sportart = isset($_GET['sp']) ? sanitize_text_field($_GET['sp']) : ''; $event_types = get_filtered_region_event_types($bundesland, $kreis, $stadt, $plz_ort); $tax_query = build_tax_query($bundesland, $kreis, $stadt, $plz_ort, $sportart); $veranstaltung_post_ids = []; if (!empty($event_types)) { $args = [ 'post_type' => 'post', 'posts_per_page' => -1, 'meta_query' => [['key' => 'veranstaltung', 'compare' => 'EXISTS']], ]; $query = new WP_Query($args); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $veranstaltungen = get_field('veranstaltung'); if ($veranstaltungen) { foreach ($veranstaltungen as $veranstaltung_id) { $terms = wp_get_post_terms($veranstaltung_id, 'event-type', ['fields' => 'ids']); if (array_intersect($event_types, $terms)) { $veranstaltung_post_ids[] = get_the_ID(); break; } } } } wp_reset_postdata(); } } $query_args['tax_query'] = $tax_query; $query_args['post__in'] = !empty($veranstaltung_post_ids) ? array_unique($veranstaltung_post_ids) : [0]; return $query_args; }, 10, 2); add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) { $relation = 'veranstaltung'; $elementClass = 'event-filter'; // Apply the suppress_query_filters functionality $query_args = suppress_query_filters( $query_args ); // Check for specific className in attributes and ensure we're not in admin if ( ! empty( $attributes['className'] ) && strpos( $attributes['className'], $elementClass) !== false && ! is_admin() ) { // Get the related post ID $queried_object = get_queried_object(); $relationship = get_field( $relation, $queried_object ); // Merge the post__in query argument with the existing one return array_merge( $query_args, array( 'post__in' => $relationship, ) ); } return $query_args; }, 10, 2 ); ?> 'AND']; $bundesland = isset($_GET['bl']) ? sanitize_text_field($_GET['bl']) : ''; $kreis = isset($_GET['kr']) ? sanitize_text_field($_GET['kr']) : ''; $stadt = isset($_GET['st']) ? sanitize_text_field($_GET['st']) : ''; $plz_ort = isset($_GET['zip']) ? sanitize_text_field($_GET['zip']) : ''; $sportart = isset($_GET['sp']) ? sanitize_text_field($_GET['sp']) : ''; // Fetch ACF Options $home_events = get_field('homepage_events', 'option'); $region_events = get_field('region_event_types', 'option'); $event_types = []; // Check each region event row if (!empty($region_events)) { foreach ($region_events as $region_event) { // Check each term in the arrays for a match $matched = false; if (!empty($bundesland) && isset($region_event['bundesland']) && is_array($region_event['bundesland'])) { foreach ($region_event['bundesland'] as $term) { if ($term->slug == $bundesland) { $matched = true; break; } } } if (!empty($kreis) && !$matched && isset($region_event['kreis']) && is_array($region_event['kreis'])) { foreach ($region_event['kreis'] as $term) { if ($term->slug == $kreis) { $matched = true; break; } } } if (!empty($stadt) && !$matched && isset($region_event['stadt']) && is_array($region_event['stadt'])) { foreach ($region_event['stadt'] as $term) { if ($term->slug == $stadt) { $matched = true; break; } } } if (!empty($plz_ort) && !$matched && isset($region_event['plz-ort']) && is_array($region_event['plz-ort'])) { foreach ($region_event['plz-ort'] as $term) { if ($term->slug == $plz_ort) { $matched = true; break; } } } if ($matched && isset($region_event['kind_of_event']) && is_array($region_event['kind_of_event'])) { $event_types = array_merge($event_types, $region_event['kind_of_event']); } } } // If no specific region is specified, use home events if (empty($bundesland) && empty($kreis) && empty($stadt) && empty($plz_ort)) { $event_types = $home_events; } if (!empty($event_types)) { $args['tax_query'][] = [ 'taxonomy' => 'event-type', 'field' => 'term_id', 'terms' => $event_types, ]; } // Additional tax queries if (!empty($bundesland)) { $args['tax_query'][] = [ 'taxonomy' => 'bundesland', 'field' => 'slug', 'terms' => $bundesland, ]; } if (!empty($kreis)) { $args['tax_query'][] = [ 'taxonomy' => 'kreis', 'field' => 'slug', 'terms' => $kreis, ]; } if (!empty($stadt)) { $args['tax_query'][] = [ 'taxonomy' => 'stadt', 'field' => 'slug', 'terms' => $stadt, ]; } if (!empty($plz_ort)) { $args['tax_query'][] = [ 'taxonomy' => 'plz-ort', 'field' => 'slug', 'terms' => $plz_ort, ]; } if (!empty($sportart)) { $args['tax_query'][] = [ 'taxonomy' => 'sportart', 'field' => 'slug', 'terms' => $sportart, ]; } return $args; } return $args; } ?> 'names')); // Construct the address string $full_address_components = array_filter([$venue_address, !empty($venue_post_term) ? $venue_post_term[0] : null]); $full_address = implode(', ', $full_address_components); if (!empty($venue_name) || !empty($full_address)) { // If both address and venue name are empty, use the venue name for the map $location_for_map = !empty($full_address) ? $full_address : $venue_name; $base_url = 'https://www.google.com/maps/search/?api=1'; $encoded_location = urlencode($location_for_map); $link_url = "{$base_url}&query={$encoded_location}"; $link_html = sprintf( '%s', esc_url($link_url), __('Google Maps', 'the-events-calendar') ); $block_content = $link_html; } else { // If there is no valid address, ensure the content is empty $block_content = str_replace($string, '', $block_content); } } return $block_content; }, 10, 2); add_filter('generateblocks_query_loop_args', function ($query_args, $attributes) { $element_meta_map = [ 'termin-ort' => '_EventVenueID', 'termin-organizer' => '_EventOrganizerID', 'termin-news' => 'veranstaltung', 'termin-clubs' => 'teilnehmende_vereine', 'termin-sportler' => 'sportler', 'orgachef' => 'kontakt_orga_chef_name' ]; if (!empty($attributes['className']) && !is_admin()) { foreach ($element_meta_map as $elementClass => $meta_key) { if (strpos($attributes['className'], $elementClass) !== false) { $current_post_id = get_the_ID(); // Use a different method for fields that need specific handling if ($elementClass == 'termin-news') { $query_args['meta_query'][] = [ 'key' => $meta_key, 'value' => '"' . $current_post_id . '"', 'compare' => 'LIKE' ]; } elseif ($elementClass == 'termin-clubs' || $elementClass == 'orgachef') { // Use get_field for ACF fields that return an array of IDs $relationship = get_field($meta_key, $current_post_id); if (!empty($relationship)) { $query_args['post__in'] = isset($query_args['post__in']) ? array_merge($query_args['post__in'], (array) $relationship) : (array) $relationship; } else { $query_args['post__in'] = [0]; } } else { $meta_values = get_post_meta($current_post_id, $meta_key, false); if (!empty($meta_values)) { $query_args['post__in'] = isset($query_args['post__in']) ? array_merge($query_args['post__in'], (array) $meta_values) : (array) $meta_values; } else { $query_args['post__in'] = [0]; } } } } } return $query_args; }, 10, 2); ?> 'AND']; // Fetch and sanitize URL parameters $bundesland = isset($_GET['bl']) ? sanitize_text_field($_GET['bl']) : ''; $kreis = isset($_GET['kr']) ? sanitize_text_field($_GET['kr']) : ''; $stadt = isset($_GET['st']) ? sanitize_text_field($_GET['st']) : ''; $plz_ort = isset($_GET['zip']) ? sanitize_text_field($_GET['zip']) : ''; $sportart = isset($_GET['sp']) ? sanitize_text_field($_GET['sp']) : ''; // Check if the 'ueberall' field is set (ACF checkbox field) $ueberall = isset($_GET['ueberall']) ? sanitize_text_field($_GET['ueberall']) : ''; if ($ueberall === 'yes') { // If ueberall is 'yes', set up a query to include only ads with this field set $meta_query = [ [ 'key' => 'ueberall', // ACF field name 'value' => 'ja', 'compare' => '=' ] ]; $args['meta_query'] = $meta_query; // Skip the rest of the taxonomy queries return $args; } // Additional tax queries based on URL parameters if (!empty($bundesland)) { $tax_query[] = [ 'taxonomy' => 'bundesland', 'field' => 'slug', 'terms' => $bundesland, ]; } if (!empty($kreis)) { $tax_query[] = [ 'taxonomy' => 'kreis', 'field' => 'slug', 'terms' => $kreis, ]; } if (!empty($stadt)) { $tax_query[] = [ 'taxonomy' => 'stadt', 'field' => 'slug', 'terms' => $stadt, ]; } if (!empty($plz_ort)) { $tax_query[] = [ 'taxonomy' => 'plz-ort', 'field' => 'slug', 'terms' => $plz_ort, ]; } if (!empty($sportart)) { $tax_query[] = [ 'taxonomy' => 'sportart', 'field' => 'slug', 'terms' => $sportart, ]; } // Append tax_query to $args only if it's not empty if (!empty($tax_query)) { $args['tax_query'] = $tax_query; } } return $args; } ?>
Zum Inhalt springenHamburg-Sport.de
Eure Infos an redaktion@hamburg-sport.de
datum
17. Wertungslauf des Elbe-Ohre-Cups
Bereich | Name | Telefon |
---|