Archived topic
Description categories below
3 replies · Started by Selina on November 3, 2021
Hi! I updated the theme today and the category descriptions have been placed at the beginning of the products, before I had it at the end of the products with this code:
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
add_action( 'woocommerce_after_shop_loop', 'woocommerce_taxonomy_archive_description', 100 );
I am trying to find other code to put the descriptions below but none works. Any ideas?
Thanks!
Hi Selina,
How did you add the snippet?
If you added it in the GP theme's functions.php file, it will be erased when the theme gets updated.
Let me know if it's the case :)
I have already solved it :)
I have added this new code:
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;
}
But I really don't understand why the above code doesn't work. I have a plugin where I add the code with the custom modifications.
The code has some errors, it should not work.
If you only want the changes apply on category archive page, try this snippet:
add_action( 'wp', function() {
if ( is_product_category() ) {
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
add_action( 'woocommerce_after_shop_loop', 'woocommerce_taxonomy_archive_description', 10 );
}
} );
Let me know :)