I'm trying to display some data in columns in php with wordpress. I have the next snippet to do that:
$args = array(
'taxonomy' => $taxonomy,
'orderby' => $orderby,
'show_count' => $show_count,
'pad_counts' => $pad_counts,
'hierarchical' => $hierarchical,
'title_li' => $title,
'parent' =>19,
'hide_empty' => $empty
);
$columnas=0;
$all_categories = get_categories( $args );
echo '<table><tr>';
foreach ($all_categories as $cat) {
$category_id = $cat->term_id;
if((($columnas%4)!==0)and($columnas!==0)){
echo '<td><a href="'. get_term_link($cat->slug, 'product_cat') .'">'. $cat->name .'</a></td>';
$columnas=$columnas+1;
echo 'Las columnas son: '.$columnas.'<br/>';
}else
{
echo 'Columnas es: '.$columnas;
echo '<td><a href="'. get_term_link($cat->slug, 'product_cat') .'">'. $cat->name .'</a></td></tr><tr>';
}
}
echo '</tr></table>';
So what I'm doing wrong?, I don't get what I want which is a table with four columns and many rows. Surely, it's a silly thing but I don't see it.