snippet 1 min read PHP 7.4+ WP 5.0+ WC 3.0+
Add WooCommerce Support to a WordPress Theme
Declare WooCommerce support in a classic WordPress theme with the after_setup_theme hook.
Updated Dec 1, 2025 #woocommerce #wordpress #php #themes #snippet
A classic WordPress theme should explicitly declare WooCommerce support instead of assuming the plugin is active. Add this during theme setup:
function mytheme_add_woocommerce_support() { add_theme_support( 'woocommerce' );}add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );Place the snippet in the active theme or child theme’s functions.php. The after_setup_theme hook runs early enough for WooCommerce to detect the declaration correctly.