Код: Выделить всё
print_r(get_the_terms( $_product->id, 'product_cat'));
Код: Выделить всё
Array ( [0] => stdClass Object ( [term_id] => 67 [name] => Paintings [slug] => paintings [term_group] => 0 [term_taxonomy_id] => 67 [taxonomy] => product_cat [description] => [parent] => 0 [count] => 44 ) [1] => stdClass Object ( [term_id] => 13 [name] => Small [slug] => small [term_group] => 0 [term_taxonomy_id] => 13 [taxonomy] => product_cat [description] => [parent] => 0 [count] => 15 ) )
Код: Выделить всё
$array[get_the_terms( $_product->id, 'product_cat')->name] = $_product->get_title()
Код: Выделить всё
$_product->get_title()Код: Выделить всё
expected output Array ( [Paintings] => A Quiet Day )
Код: Выделить всё
$array[] = $_product->get_title();
Код: Выделить всё
Array ( [0] => A Quiet Day )
Подробнее здесь: https://stackoverflow.com/questions/206 ... of-objects
Мобильная версия