I have existing PHP code to list product categories as a list of links:
<?php // as per https://phptechnologytutorials.wordpress.com/2015/11/07/get-
list-of-all-woocommerce-categories/
$orderby = 'name';
$order = 'asc';
$hide_empty = false;
$excluded = '32';
$cat_args = array(
'orderby' => $orderby,
'order' => $order,
'hide_empty' => $hide_empty,
'exclude' => $excluded,
);
$product_categories = get_terms( 'product_cat', $cat_args );
if( !empty($product_categories) ){
echo '<ul class="linked-product-category-list">';
foreach ($product_categories as $key => $category) {
echo '<li>';
echo '<a href="'.get_term_link($category).'" >';
echo $category->name;
echo '</a>';
echo '</li>';
}
echo '</ul>';
}
?>
I found another Stack Overflow solution which demonstrates how to do what I want to achieve - to arrange list of items into 4 equally populated columns.
However, I'm new to PHP and I don't know how to adapt the solution into my own code above. Please help me to adapt my code above using the principles of the solution below to split up my list into columns.
<?php
$col = 3;
$projects = array_chunk($projects, ceil(count($projects) / $col));
foreach ($projects as $i => $project_chunk)
{
echo "<ul class='pcol{$i+1}'>";
foreach ($project_chunk as $project)
{
echo "<li>{$project->name}</li>";
};
echo "</ul>";
}; ?>