Search code examples
phpwordpresstemplateswoocommercehook-woocommerce

Adding a text on WooCommerce main shop page after the product loop


I am looking in the WordPress with WooCommerce for help to insert the text after the product loop (same as category description) on the main shop page only. Does anyone have any ideas how can it be done?

  • Main shop page only
  • Not if the category is selected
  • Not in page 2nd, 3rd, and so on...

Will be thankful if anyone knows how to improve this function.


Solution

  • To display a text after the product loop, on first page of the shop page only, try the following:

    add_action('woocommerce_after_shop_loop', 'add_text_after_shop_loop', 100 );
    function add_text_after_shop_loop() {
        global $woocommerce_loop;
    
        if( is_shop() && isset($woocommerce_loop['current_page']) && $woocommerce_loop['current_page'] == 1 ) {
            echo '<div class="shop-description" style="clear:both;">
                <p>' . __('This is some text added after the shop loop, on first page only…','woocommerce') . '</p>
            </div>';
        }
    }
    

    Code goes in functions.php file of your child theme (or in a plugin). Tested and work.