Enhancing the design and layout of your WooCommerce Product Category archive pages can significantly impact the user experience. One common customization involves the strategic placement of the category description. By default, WooCommerce displays this description above the loop of products, but what if you prefer it to appear after the list of items? In this post, we’ll explore a simple and effective solution using a custom code snippet.
/**
* Snippet Name: Display category description after product list in bottom
* Snippet Author: wpsnippets.dev
*/
//Moving Category Description After Loop Items (Product Category Archive Only)
function wps_display_description_at_bottom() {
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 );
}
}
add_action('woocommerce_archive_description', 'wps_display_description_at_bottom', 2 );
Code Explanation
- This code snippet utilizes the add_action function to hook into the woocommerce_archive_description action. If the current page is a Product Category archive (if (is_product_category())), it removes the default action that displays the category description above the loop (woocommerce_taxonomy_archive_description) and adds a new action after the main content (woocommerce_after_main_content) with a priority of 5. This ensures that the category description is moved and displayed after the loop of product items on the Product Category archive pages.