0
Talk personal, all right? I hope so! I’m having a hard time solving the following problem. I have a Post_type Called prize and a taxonomy called winners, in the post I have a repeater field where register winners, I can add name, logo, and category (she is pulled as I register the categories in my taxonomy), They’re all FCA camps! Also, I have a select of years and an ajax request to filter posts per year, so far so good, but at the time of lists the posts need to list all winners of the repeater field following the rule that they will be separated according to their category.
Example: Winner 01 = name: so-and-so: logo = test Category: Seller Winner 02 = name: so-and-so: logo = test Category: Seller Winner 03 = name: so-and-so: logo = test Category: Builder Winner 04 = name: so-and-so: logo = test Category: Builder
*Each Winner with the same category needs to stay in a separate html column.
Column 01 Winner 01 Winner 02
Column 02 Winner 03 Winner 04
My ajax function is this one:
add_action('wp_ajax_nopriv_rankings-filter', 'filter_rankings');
add_action('wp_ajax_rankings-filter', 'filter_rankings');
function filter_rankings()
{
$html = '';
$year = $_POST['ano'];
$args = array(
'orderby' => 'title',
'order' => 'ASC',
'post_status' => 'publish',
'post_type' => 'top_imobiliario',
'date_query' => array(
array(
'year' => $year,
),
),
);
$query = new WP_Query($args);
if ($query->have_posts()) :
while ($query->have_posts()) : $query->the_post();
$dateAno = get_the_date('Y');
$vencedor = get_field('vencedores_do_premio');
foreach ($vencedor as $vencedores) {
$nome = $vencedores['nome_do_vencedor'];
$logo = $vencedores['logo_do_vencedor'];
$categoria = $vencedores['categoria_do_vencedor'];
$html .= '<div class="single-vencedor col-md-4">';
$html .= '<div class="bloco-img-vencedor">';
$html .= '<img src="'.$logo.'" alt="Logo vencedor">';
$html .= '</div>';
$html .= '<h6>' . $nome . '</h6>';
$html .= '</div>';
}
wp_reset_postdata();
endwhile;
else :
endif;
echo $html;
exit;
}
Great guy, it worked super well. Thank you so much
– Natanael Oliveira