Classic woocommerce theme support
Skill Lonsdale201/wp-agent-skills/theme-development/classic-woocommerce-theme-support
Build or audit WooCommerce support in a classic PHP WordPress theme. Covers `add_theme_support( 'woocommerce' )`, `wc_current_theme_supports_woocommerce_or_fse()`, supported vs unsupported theme rendering, shop/single wrappers, `woocommerce_before_main_content` and `woocommerce_after_main_content`, product image widths, `product_grid`, gallery zoom/lightbox/slider support, Woo body/post classes, conditional asset loading with `is_woocommerce()`/`is_shop()`/`is_product()`, and the classic-theme boundary versus Woo block templates.From its SKILL.md
npx -y skills add Lonsdale201/wp-agent-skills --skill classic-woocommerce-theme-supportAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 21 stars21 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
9.0 KB, ~1.8k tokens by cl100k_base, as published. Nobody here has run it
Classic WooCommerce Theme Support
Use this when creating or reviewing a classic PHP theme that must support WooCommerce shop, taxonomy, product, cart, checkout, and account screens.
This is not a block-theme skill. If the theme uses HTML block templates or the Site Editor as its primary rendering model, use Woo block-theme documentation instead.
When to Use This Skill
- Adding WooCommerce compatibility to a classic theme.
- Fixing a shop page that renders through unsupported shortcode/content fallback.
- Aligning Woo wrappers with the theme's
page.php/single.phpstructure. - Setting Woo image sizes, product grid defaults, or gallery features.
- Loading frontend assets only on Woo screens.
- Reviewing whether a theme should override Woo templates at all.
Declare Support
Declare WooCommerce support on after_setup_theme.
add_action( 'after_setup_theme', 'mytheme_woocommerce_support' );
function mytheme_woocommerce_support() {
add_theme_support(
'woocommerce',
array(
'thumbnail_image_width' => 360,
'single_image_width' => 720,
'product_grid' => array(
'default_rows' => 4,
'min_rows' => 2,
'max_rows' => 6,
'default_columns' => 3,
'min_columns' => 2,
'max_columns' => 4,
),
)
);
}
Rules:
- A classic theme that ships Woo template overrides must declare Woo support.
- Without support, Woo treats the theme as unsupported and uses fallback content rendering for shop/product pages.
wc_current_theme_supports_woocommerce_or_fse()returns true when the classic theme supports Woo or when the active theme is a block theme.- Do not declare support from a plugin unless the plugin truly owns the active theme.
Image Sizes
Woo reads theme support values through wc_get_theme_support() and wc_get_image_size().
Supported keys:
thumbnail_image_widthfor catalog/grid images.single_image_widthfor single product main images.gallery_thumbnail_image_widthfor gallery thumbnails.
Rules:
- If the theme defines image widths, Woo hides the matching Customizer controls from users.
- If the theme does not define widths, store owners can control image sizes from Woo settings/Customizer.
- After changing sizes, existing uploads may need thumbnail regeneration.
- Do not register separate conflicting product image sizes unless the design genuinely needs them.
Product Grid Defaults
product_grid controls default/min/max rows and columns for classic catalogs.
Rules:
- Use grid defaults that match the theme's responsive layout.
- Set min/max values to prevent broken designs at extremes.
- Woo resets catalog rows/columns on theme switch via
wc_reset_product_grid_settings(). - Do not hardcode product counts in templates when Woo loop props/settings already control the loop.
Gallery Feature Support
Declare only features the theme CSS/JS can support.
add_action( 'after_setup_theme', 'mytheme_woocommerce_gallery_support' );
function mytheme_woocommerce_gallery_support() {
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
}
Rules:
- Test simple, variable, grouped, and external products.
- Do not declare gallery support if the theme hides thumbnails or breaks gallery focus/keyboard behavior.
- Product gallery templates changed in Woo 10.x; avoid overriding them unless necessary.
Main Content Wrappers
Woo's default wrappers are hooked to:
woocommerce_before_main_content->woocommerce_output_content_wrapperat priority 10.woocommerce_after_main_content->woocommerce_output_content_wrapper_endat priority 10.
If default wrappers do not match the theme, replace them with theme-specific wrappers.
add_action( 'wp', 'mytheme_woocommerce_wrappers' );
function mytheme_woocommerce_wrappers() {
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
add_action( 'woocommerce_before_main_content', 'mytheme_woocommerce_wrapper_start', 10 );
add_action( 'woocommerce_after_main_content', 'mytheme_woocommerce_wrapper_end', 10 );
}
function mytheme_woocommerce_wrapper_start() {
echo '<main id="main" class="site-main">';
}
function mytheme_woocommerce_wrapper_end() {
echo '</main>';
}
Rules:
- Match the structure used by the theme's normal content templates.
- Do not create nested
<main>landmarks. - Keep
woocommerce_before_main_contentandwoocommerce_after_main_contentin overridden Woo templates. - Do not fix wrapper problems by copying every Woo template.
Body and Product Classes
Woo adds body and post/product classes through:
wc_body_classonbody_class.wc_product_post_classonpost_class.wc_product_class()in product templates.
Rules:
- Do not replace
body_class()orpost_class()output in the theme. - In product loop overrides, preserve
wc_product_class( '', $product ). - CSS should target Woo classes instead of brittle URL or page-title selectors.
Conditional Assets
Use Woo conditionals after query setup, such as on wp_enqueue_scripts.
add_action( 'wp_enqueue_scripts', 'mytheme_woocommerce_assets' );
function mytheme_woocommerce_assets() {
if ( is_woocommerce() || is_cart() || is_checkout() || is_account_page() ) {
wp_enqueue_style(
'mytheme-woocommerce',
get_theme_file_uri( 'assets/css/woocommerce.css' ),
array(),
wp_get_theme()->get( 'Version' )
);
}
}
Rules:
- Do not call Woo conditional tags at file load time in
functions.php. - Woo docs note that conditionals work after query setup;
wpis the earliest safe general hook. - Cart, checkout, and account pages are not always covered by
is_woocommerce(). - Avoid loading shop-only scripts on the whole site.
Block Boundary
This skill is for classic PHP templates. Still be aware:
- Woo 10.x includes block template compatibility layers.
- Classic themes should not add
/templates/*.htmlWoo block templates unless intentionally moving into block-theme territory. - Checkout/Cart blocks may appear on pages even in classic themes; theme CSS should not assume only shortcode checkout exists.
- Do not edit Woo block internals from classic PHP theme templates.
Review Checklist
add_theme_support( 'woocommerce' )runs onafter_setup_theme.- Product image widths and grid settings are intentional.
- Gallery supports are declared only when tested.
- Woo wrappers match the theme's content structure.
- No duplicate
<main>or landmark conflicts. - Woo body/product classes are preserved.
- Assets are conditionally enqueued on Woo screens.
- The theme does not copy Woo templates just to change wrappers.
- Block-theme and classic-template assumptions are not mixed.
Common Mistakes
- Shipping
woocommerce/template overrides without declaring Woo support. - Using unsupported-theme fallback as if it were the normal integration path.
- Calling
is_shop()in the body offunctions.php. - Replacing
wc_product_class()with plainpost_class(). - Hardcoding
fullproduct images in archives. - Declaring gallery slider/lightbox support without keyboard/focus testing.
References
- Official documentation: https://developer.woocommerce.com/docs/theming/theme-development/classic-theme-developer-handbook/
- Official documentation: https://developer.woocommerce.com/docs/theming/theme-development/template-structure/
- Official documentation: https://developer.woocommerce.com/docs/theming/theme-development/image-sizes/
- Official documentation: https://developer.woocommerce.com/docs/theming/theme-development/conditional-tags/
- Verified source paths:
wp-content/plugins/woocommerce/woocommerce.phpwp-content/plugins/woocommerce/includes/class-wc-template-loader.phpwp-content/plugins/woocommerce/includes/wc-conditional-functions.phpwp-content/plugins/woocommerce/includes/wc-core-functions.phpwp-content/plugins/woocommerce/includes/wc-template-functions.phpwp-content/plugins/woocommerce/includes/wc-template-hooks.phpwp-content/plugins/woocommerce/templates/global/wrapper-start.phpwp-content/plugins/woocommerce/templates/global/wrapper-end.php
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.