I found this code to show attribute after a title: Add specific product attribute after title on Woocommerce single products
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_single_product_summary', 'custom_template_single_title', 5 );
function custom_template_single_title() {
global $product;
$brand_name = $product->get_attribute('brand-name');
echo '<h1 class="product_title entry-title">';
the_title();
if( $brand_name )
echo ' - ' . $brand_name;
echo '</h1>';
}
is work but, i try to show only one the selected attribute to appear.
An example attribute from color: white and black
The code works like
"Product Title - White, Color"
What i want to show is
if not selected any attribute
"Product Title"(not to appear anything)
if selected white, show like
"Product Title - White"