Я нашел подходящий код, который мне подходит, но я хочу, чтобы подкатегории отображались горизонтально (вместо перечисленных сверху вниз) и без маркеров с правой стороны. Также мне нужно, чтобы они выглядели как кнопки (например, цвет фона с отступами).
Есть предложения?
текущий код:
$categories = get_the_terms( get_the_ID(), 'product_cat' );
//For checking category exit or not
if ( $categories && ! is_wp_error( $category ) ) :
foreach($categories as $category) :
// get the children (if any) of the current cat
$children = get_categories( array ('taxonomy' => 'product_cat', 'parent' => $category->term_id ));
if ( count($children) == 0 ) {
// if no children, then echo the category name.
echo $category->name;
}
endforeach;
endif;