Archived topic
Product attributes description on attribute page under the products
6 replies · Started by retroreiz on February 3, 2020
Hello everybody,
how can I display the description of the attributes on the attribute page below products?
Example: https://ibb.co/R4cRzgw
Thank you in advance.
Greetings, Andreas
Hi there,
try this PHP snippet to move the Description on the Product Archives:
add_action('woocommerce_archive_description', 'custom_archive_description', 2 );
function custom_archive_description(){
if( is_product_category() ) :
remove_action('woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
add_action( 'woocommerce_after_main_content', 'woocommerce_taxonomy_archive_description', 5 );
endif;
}
Hi David,
many thanks for the answer.
Unfortunately, this snippet only works on category descriptions. This snippet does not apply to attributes descriptions.
What should the code be for the attributes archive page to work?
Thanks and have a nice day.
Greetings, Andreas
Do you need to move the description on all archives? so Category, Tags, Attributes etc
Let me know
Hello David,
only attributes.
But if there is no other way, then also in categories, tags, attributes etc.
Thank you.
Greetings, Andreas
So i found this function:
function my_is_wc_attribute() {
/**
* Attributes are proper taxonomies, therefore first thing is
* to check if we are on a taxonomy page using the is_tax().
* Also, a further check if the taxonomy_is_product_attribute
* function exists is necessary, in order to ensure that this
* function does not produce fatal errors when the WooCommerce
* is not activated
*/
if ( is_tax() && function_exists( 'taxonomy_is_product_attribute') ) {
// now we know for sure that the queried object is a taxonomy
$tax_obj = get_queried_object();
return taxonomy_is_product_attribute( $tax_obj->taxonomy );
}
return false;
}
Original source: https://wordpress.stackexchange.com/a/333460
With that function added you should be able to do this:
add_action('woocommerce_archive_description', 'custom_archive_description', 2 );
function custom_archive_description(){
if( my_is_wc_attribute() ) :
remove_action('woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
add_action( 'woocommerce_after_main_content', 'woocommerce_taxonomy_archive_description', 5 );
endif;
}
Hello David,
you are great!!!!
It works wonderfully :)
Thank you very much.
Greetings, Andreas