$terms = wp_list_filter($terms, array('slug'=>'myslug'),'NOT');
Buradaki NOT hariç tutmak için kullanılıyor, dahil etmek için değil.
mantığı anlamak için soruyorum hocam böyle mi yapmam gerek ?
add_action( 'woocommerce_shop_loop_item_title', 'custom_attributes_display', 20 );
function custom_attributes_display(){
global $product;
// Just for simple products
if( ! $product->is_type( 'simple' ) ) return;
$loop_count = 0;
echo '<div>';
$terms = wp_get_post_terms( $post->ID, 'wedding_cat');
$terms = wp_list_filter($terms, array('slug'=>'myslug'),'88');
// Get the attributes taxonomy slugs (Updated and dynamic now)
$terms = $attributes_taxonomy;
$attributes_taxonomy = $product->get_attributes();
// OR set an indexed array of taxonomy slug (key) and name (value) to chose which ones, like:
// $attributes_taxonomy = array('pa_nopeus' => 'Nopeus', 'pa_liito' => 'Liito, 'pa_vakaus' => 'Vaukaus' );
foreach( $attributes_taxonomy as $taxonomy => $attribute ) {
// Getting the term names of an attribute (set in a coma separated string if many values)
$attribute_terms = wp_get_post_terms( get_the_id(), $taxonomy, array( 'fields' => 'names' ) );
$terms_string = implode( ',', $attribute_terms );
// Displays only if attribute exist for the product
if( count( $attribute_terms ) > 0 ){ // Updated
echo '<p style="border:solid">'.$attribute->get_name().' : '.$terms_string.'</p>';
// Separating each number by a " | " (Updated and dynamic now)
$attr_count = count( $attributes_taxonomy );
$loop_count++;
}
}
echo '</div>';
}