Search code examples
phpwordpresswoocommerceproductcustom-taxonomy

Move product category description after displayed category products in Woocommerce


i have one issue with Category Description text Currently is placed on top of product category, and i want to place it at bottom after products.

category description

class that is control that part is:

.term-description

and want to place here, after all category products:

enter image description here

I found this function:

function woocommerce_taxonomy_archive_description() {
if ( is_tax( array( 'product_cat', 'product_tag' ) ) && get_query_var( 'paged' ) == 0 ) {
    $description = wpautop( do_shortcode( term_description() ) );
    if ( $description ) {
        echo '<div class="term-description">' . $description . '</div>';
    }
}
}

but not works.. Can someone to help me with this? i want to move only category desctiption without title at top.


Solution

  • The following hooked function will move only product category description after the loop display:

    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;
    }
    

    Code goes in function.php file of your active child theme (or active theme). Tested and works.