On my Woocommerce site, I have 2 different product attributes (artist and type). I want to execute some code when on a attribute archive page containing one of those attributes and their value. For example:
on site.com/artist/rembrandt/ showing all products made by Rembrandt (pa_rembrandt), I want to add the text "please see all painings by Rembrandt" etc. This is what I tried so fare:
<?php add_action( 'woocommerce_archive_description', 'artist_description' );
function artist_description() {
if (is_product_taxonomy() && is_tax(pa_artist)) {
echo "Please see all paintings made by";
echo is_tax(pa_artist));
echo ".";
}
} ?>
But that clearly is not working. When I remove the && is_tax(pa_artist)
the code does show the text "Please see all paintings made by." but without the actual painter and turns up on every archive page. Who can help me? Thanks in advance.
3
Answers
I found a solution by using (and stripping) the title and changing the code to this:
Try this code below. It will add the text on every archive page/ listing page in products grid after product title. This text will show on specific products in which you have added this attribute.