
I have a repeater with buttons inside, but I only want to get one instance of each for filtering buttons.
$all_attributes = array();
$filter_attributes = array();
if( have_rows('applications', 350) ):
$html_out = '';
$html_out .= '<div id="applications">';
$html_out .= '<div class="controls">';
while( have_rows('applications', 350) ): the_row();
// vars
$name = get_sub_field('application_name', 350);
$field = get_sub_field_object('application_filters', 350);
$filters = $field['value'];
// $content = get_sub_field('content');
// $link = get_sub_field('link');
if($filters) {
foreach( $filters as $filter ){
array_push($all_attributes, $filter);
}
}
endwhile;
$filter_attributes = array_unique($all_attributes);
$html_out .= '<button type="button" class="control" data-filter="all">All</button>';
foreach( $filter_attributes as $filter_attribute ) {
$filter = create_filter_class($filter_attribute);
$html_out .= '<button type="button" class="control" data-filter=".' . $filter . '">' . $filter_attribute . '</button>';
}
$html_out .= '</div>'; // controls
return $html_out;
endif;
I’m getting this error though “Invalid argument supplied for foreach()”. Can I not do foreach’s on radio buttons?