I’m trying to get a list of categories into two columns. Each category has a custom field ("color") created with ACF. So far so good, i can get the list in a single column with this code:
<?php
$args = array( 'hide_empty' => '0');
$categories = get_categories($args);
if($categories){
echo '<div class="col"><ul class="cat-list">';
foreach($categories as $category) {
$color = get_field('color', 'category_'.$category->term_id);
echo '<li style="background-color:'.$color.'">';
echo '<a href="';
echo esc_url( get_category_link( $category->term_id ) );
echo '">';
echo $category->name;
echo '</a>';
echo '</li>';
}
echo '</ul></div>';
}
?>
Now i’m trying to get the list using wp_list_categories (tip: https://wpsquare.com/display-wordpress-categories-two-columns/). This works as a solution for the two columns issue, but with this method i can’t retrieve the value from the category custom field.
Thanks in advance.