Hi @savvasha
Thanks for the data details. I added the query to event-list.php to pull the match data from Sportspress
$home_team = sp_get_team_name(get_the_ID(), 'home');
$home_score = sp_get_team_result(get_the_ID(), 'home');
$away_team = sp_get_team_name(get_the_ID(), 'away');
$away_score = sp_get_team_result(get_the_ID(), 'away');
$match_time = get_post_meta(get_the_ID(), 'sp_date', true);
$match_date_readable = date_i18n(get_option('date_format'), strtotime($match_time));
$league = wp_get_post_terms(get_the_ID(), 'sp_league', array('fields' => 'names'));
I applied it for the Alchemists marquee display to pull it dynamically.
<div class="marquee-wrapper">
<div class="container">
<div class="marquee">
<div class="marquee-content">
<?php
// Query by date range
$args = array(
'post_type' => 'sp_event',
'post_status' => array('publish', 'future'), // Both scheduled and broadcasted matches
'posts_per_page' => 100, // Maximum matches
'date_query' => array(
array(
'before' => date('Y-m-d', strtotime('+4 days')), // Up to 4 days later
'after' => date('Y-m-d', strtotime('-4 days')), // Until 4 days ago
'inclusive' => true,
),
),
);
// SportPress query to capture matches
$events_query = new WP_Query($args);
$matches_by_league = array(); // To group matches by leagues
$processed_matches = array(); // To avoid showing the same match twice
if ($events_query->have_posts()) :
while ($events_query->have_posts()) : $events_query->the_post();
// Get match ID
$match_id = get_the_ID();
// Get team names
$home_team = sp_get_team_name($match_id, 'home');
$away_team = sp_get_team_name($match_id, 'away');
// Fetch post metadata for match time
$match_time = get_post_meta($match_id, 'sp_date', true);
// If the date information is empty or null, use a default information.
if (empty($match_time)) {
$match_time = null; // Default value: Unknown
} else {
$match_time = date('Y-m-d H:i', strtotime($match_time)); // Date format
}
// League information
$league = wp_get_post_terms($match_id, 'sp_league', array('fields' => 'names'));
// Check date format
$formatted_time = $match_time ? date('d.m.Y H:i', strtotime($match_time)) : 'Bilinmiyor';
// If there is league information, let's process it
if (!empty($league)) {
$league_output = implode(', ', $league);
$home_score = function_exists('sp_get_team_result') ? sp_get_team_result($match_id, 'home') : null;
$away_score = function_exists('sp_get_team_result') ? sp_get_team_result($match_id, 'away') : null;
// Generate a unique key: Using the match ID we prevent the same match from being added twice
$match_key = $match_id;
// Check to avoid adding the same match twice
if (!in_array($match_key, $processed_matches)) {
$is_past = $match_time && strtotime($match_time) < time(); // Check if the match is past or future
// Only show as played if the score is full and the match is in the past
if ($is_past && $home_score !== null && $away_score !== null) {
// If the match has been played, show the score
$matches_by_league[$league_output][] = $home_team . ' ' . $home_score . ' - ' . $away_score . ' ' . $away_team;
} else if (!$is_past) {
// If in the future and there is no score, show match details
$matches_by_league[$league_output][] = $home_team . ' vs ' . $away_team . ' (' . $formatted_time . ')';
}
// Add match to processed list
$processed_matches[] = $match_key;
}
}
endwhile;
wp_reset_postdata();
endif;
// Show matches by league
if (!empty($matches_by_league)) {
foreach ($matches_by_league as $league => $matches) {
echo $league . ': '; // Show league name
echo implode(' | ', $matches) . ' | ';
}
} else {
echo 'The weekly program was not published.';
}
?>
</div>
</div>
</div>
</div>
Flowing text on the marquee
2.Amateur League (Play-Off): Team2 vs Team1 vs Team2 vs Team1 (Unknown) | Team1 vs Team2 vs Team1 vs Team2 (Unknown)
The text planned to flow on the marquee
2.Amateur League (Play-Off): Team2 5 – 4 Team1 | Team1 vs Team2 (09 October 2024 18:30)
Matches are repeated twice in Marquee and it is not possible to pull the score and date information.
What could be the reason for this?