• Resolved agxer

    (@agxer)


    Hi all,

    i have a product category page where i sometimes display virtual products (webinar registrations) using the shortcode [product_category category=”online-events”].

    The problem is that if there are no current products the shortcode displays nothing.

    I would like if there is no products that the shortcode displays something like “There are no upcoming webinars.”

    Does anyone know how to acheive this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Mike Jolley

    (@mikejolley)

    There is an action hook.

    woocommerce_shortcode_product_category_loop_no_results

    Use that to add content.

    add_action( 'woocommerce_shortcode_product_category_loop_no_results', 'custom_woocommerce_shortcode_product_category_loop_no_results_content' );
    
    function custom_woocommerce_shortcode_product_category_loop_no_results_content() {
      echo 'Output this text';
    }
    
    Thread Starter agxer

    (@agxer)

    That worked! Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Include No Products Message with shortcodes’ is closed to new replies.