{"slug":"classic-woocommerce-theme-support","title":"classic-woocommerce-theme-support","summary":"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_a","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-09-16T14:52:13.205711Z","repo":{"url":"https://github.com/Lonsdale201/wp-agent-skills","stars":26,"forks":2,"license":"MIT","updatedAt":"2026-11-15T13:11:43Z"},"bodyHtml":"<hr>\n<h2>name: classic-woocommerce-theme-support\ndescription: Build or audit WooCommerce support in a classic PHP WordPress theme. Covers <code>add_theme_support( 'woocommerce' )</code>, <code>wc_current_theme_supports_woocommerce_or_fse()</code>, supported vs unsupported theme rendering, shop/single wrappers, <code>woocommerce_before_main_content</code> and <code>woocommerce_after_main_content</code>, product image widths, <code>product_grid</code>, gallery zoom/lightbox/slider support, Woo body/post classes, conditional asset loading with <code>is_woocommerce()</code>/<code>is_shop()</code>/<code>is_product()</code>, and the classic-theme boundary versus Woo block templates.\nmetadata:\nwp-skills-author: \"Soczó Kristóf\"\nwp-skills-contact: \"mailto:lonsdale201@hotmail.com\"\nwp-skills-plugin: \"woocommerce\"\nwp-skills-plugin-version-tested: \"10.8.1\"\nwp-skills-wp-version-tested: \"7.1\"\nwp-skills-php-min: \"7.4\"\nwp-skills-last-updated: \"2026-08-20\"</h2>\n<h1>Classic WooCommerce Theme Support</h1>\n<p>Use this when creating or reviewing a classic PHP theme that must support WooCommerce shop, taxonomy, product, cart, checkout, and account screens.</p>\n<p>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.</p>\n<h2>When to Use This Skill</h2>\n<ul>\n<li>Adding WooCommerce compatibility to a classic theme.</li>\n<li>Fixing a shop page that renders through unsupported shortcode/content fallback.</li>\n<li>Aligning Woo wrappers with the theme's <code>page.php</code>/<code>single.php</code> structure.</li>\n<li>Setting Woo image sizes, product grid defaults, or gallery features.</li>\n<li>Loading frontend assets only on Woo screens.</li>\n<li>Reviewing whether a theme should override Woo templates at all.</li>\n</ul>\n<h2>Declare Support</h2>\n<p>Declare WooCommerce support on <code>after_setup_theme</code>.</p>\n<pre><code>add_action( 'after_setup_theme', 'mytheme_woocommerce_support' );\n\nfunction mytheme_woocommerce_support() {\n\tadd_theme_support(\n\t\t'woocommerce',\n\t\tarray(\n\t\t\t'thumbnail_image_width' =&gt; 360,\n\t\t\t'single_image_width'    =&gt; 720,\n\t\t\t'product_grid'          =&gt; array(\n\t\t\t\t'default_rows'    =&gt; 4,\n\t\t\t\t'min_rows'        =&gt; 2,\n\t\t\t\t'max_rows'        =&gt; 6,\n\t\t\t\t'default_columns' =&gt; 3,\n\t\t\t\t'min_columns'     =&gt; 2,\n\t\t\t\t'max_columns'     =&gt; 4,\n\t\t\t),\n\t\t)\n\t);\n}\n</code></pre>\n<p>Rules:</p>\n<ul>\n<li>A classic theme that ships Woo template overrides must declare Woo support.</li>\n<li>Without support, Woo treats the theme as unsupported and uses fallback content rendering for shop/product pages.</li>\n<li><code>wc_current_theme_supports_woocommerce_or_fse()</code> returns true when the classic theme supports Woo or when the active theme is a block theme.</li>\n<li>Do not declare support from a plugin unless the plugin truly owns the active theme.</li>\n</ul>\n<h2>Image Sizes</h2>\n<p>Woo reads theme support values through <code>wc_get_theme_support()</code> and <code>wc_get_image_size()</code>.</p>\n<p>Supported keys:</p>\n<ul>\n<li><code>thumbnail_image_width</code> for catalog/grid images.</li>\n<li><code>single_image_width</code> for single product main images.</li>\n<li><code>gallery_thumbnail_image_width</code> for gallery thumbnails.</li>\n</ul>\n<p>Rules:</p>\n<ul>\n<li>If the theme defines image widths, Woo hides the matching Customizer controls from users.</li>\n<li>If the theme does not define widths, store owners can control image sizes from Woo settings/Customizer.</li>\n<li>After changing sizes, existing uploads may need thumbnail regeneration.</li>\n<li>Do not register separate conflicting product image sizes unless the design genuinely needs them.</li>\n</ul>\n<h2>Product Grid Defaults</h2>\n<p><code>product_grid</code> controls default/min/max rows and columns for classic catalogs.</p>\n<p>Rules:</p>\n<ul>\n<li>Use grid defaults that match the theme's responsive layout.</li>\n<li>Set min/max values to prevent broken designs at extremes.</li>\n<li>Woo resets catalog rows/columns on theme switch via <code>wc_reset_product_grid_settings()</code>.</li>\n<li>Do not hardcode product counts in templates when Woo loop props/settings already control the loop.</li>\n</ul>\n<h2>Gallery Feature Support</h2>\n<p>Declare only features the theme CSS/JS can support.</p>\n<pre><code>add_action( 'after_setup_theme', 'mytheme_woocommerce_gallery_support' );\n\nfunction mytheme_woocommerce_gallery_support() {\n\tadd_theme_support( 'wc-product-gallery-zoom' );\n\tadd_theme_support( 'wc-product-gallery-lightbox' );\n\tadd_theme_support( 'wc-product-gallery-slider' );\n}\n</code></pre>\n<p>Rules:</p>\n<ul>\n<li>Test simple, variable, grouped, and external products.</li>\n<li>Do not declare gallery support if the theme hides thumbnails or breaks gallery focus/keyboard behavior.</li>\n<li>Product gallery templates changed in Woo 10.x; avoid overriding them unless necessary.</li>\n</ul>\n<h2>Main Content Wrappers</h2>\n<p>Woo's default wrappers are hooked to:</p>\n<ul>\n<li><code>woocommerce_before_main_content</code> -&gt; <code>woocommerce_output_content_wrapper</code> at priority 10.</li>\n<li><code>woocommerce_after_main_content</code> -&gt; <code>woocommerce_output_content_wrapper_end</code> at priority 10.</li>\n</ul>\n<p>If default wrappers do not match the theme, replace them with theme-specific wrappers.</p>\n<pre><code>add_action( 'wp', 'mytheme_woocommerce_wrappers' );\n\nfunction mytheme_woocommerce_wrappers() {\n\tremove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );\n\tremove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );\n\n\tadd_action( 'woocommerce_before_main_content', 'mytheme_woocommerce_wrapper_start', 10 );\n\tadd_action( 'woocommerce_after_main_content', 'mytheme_woocommerce_wrapper_end', 10 );\n}\n\nfunction mytheme_woocommerce_wrapper_start() {\n\techo '&lt;main id=\"main\" class=\"site-main\"&gt;';\n}\n\nfunction mytheme_woocommerce_wrapper_end() {\n\techo '&lt;/main&gt;';\n}\n</code></pre>\n<p>Rules:</p>\n<ul>\n<li>Match the structure used by the theme's normal content templates.</li>\n<li>Do not create nested <code>&lt;main&gt;</code> landmarks.</li>\n<li>Keep <code>woocommerce_before_main_content</code> and <code>woocommerce_after_main_content</code> in overridden Woo templates.</li>\n<li>Do not fix wrapper problems by copying every Woo template.</li>\n</ul>\n<h2>Body and Product Classes</h2>\n<p>Woo adds body and post/product classes through:</p>\n<ul>\n<li><code>wc_body_class</code> on <code>body_class</code>.</li>\n<li><code>wc_product_post_class</code> on <code>post_class</code>.</li>\n<li><code>wc_product_class()</code> in product templates.</li>\n</ul>\n<p>Rules:</p>\n<ul>\n<li>Do not replace <code>body_class()</code> or <code>post_class()</code> output in the theme.</li>\n<li>In product loop overrides, preserve <code>wc_product_class( '', $product )</code>.</li>\n<li>CSS should target Woo classes instead of brittle URL or page-title selectors.</li>\n</ul>\n<h2>Conditional Assets</h2>\n<p>Use Woo conditionals after query setup, such as on <code>wp_enqueue_scripts</code>.</p>\n<pre><code>add_action( 'wp_enqueue_scripts', 'mytheme_woocommerce_assets' );\n\nfunction mytheme_woocommerce_assets() {\n\tif ( is_woocommerce() || is_cart() || is_checkout() || is_account_page() ) {\n\t\twp_enqueue_style(\n\t\t\t'mytheme-woocommerce',\n\t\t\tget_theme_file_uri( 'assets/css/woocommerce.css' ),\n\t\t\tarray(),\n\t\t\twp_get_theme()-&gt;get( 'Version' )\n\t\t);\n\t}\n}\n</code></pre>\n<p>Rules:</p>\n<ul>\n<li>Do not call Woo conditional tags at file load time in <code>functions.php</code>.</li>\n<li>Woo docs note that conditionals work after query setup; <code>wp</code> is the earliest safe general hook.</li>\n<li>Cart, checkout, and account pages are not always covered by <code>is_woocommerce()</code>.</li>\n<li>Avoid loading shop-only scripts on the whole site.</li>\n</ul>\n<h2>Block Boundary</h2>\n<p>This skill is for classic PHP templates. Still be aware:</p>\n<ul>\n<li>Woo 10.x includes block template compatibility layers.</li>\n<li>Classic themes should not add <code>/templates/*.html</code> Woo block templates unless intentionally moving into block-theme territory.</li>\n<li>Checkout/Cart blocks may appear on pages even in classic themes; theme CSS should not assume only shortcode checkout exists.</li>\n<li>Do not edit Woo block internals from classic PHP theme templates.</li>\n</ul>\n<h2>Review Checklist</h2>\n<ul>\n<li><code>add_theme_support( 'woocommerce' )</code> runs on <code>after_setup_theme</code>.</li>\n<li>Product image widths and grid settings are intentional.</li>\n<li>Gallery supports are declared only when tested.</li>\n<li>Woo wrappers match the theme's content structure.</li>\n<li>No duplicate <code>&lt;main&gt;</code> or landmark conflicts.</li>\n<li>Woo body/product classes are preserved.</li>\n<li>Assets are conditionally enqueued on Woo screens.</li>\n<li>The theme does not copy Woo templates just to change wrappers.</li>\n<li>Block-theme and classic-template assumptions are not mixed.</li>\n</ul>\n<h2>Common Mistakes</h2>\n<ul>\n<li>Shipping <code>woocommerce/</code> template overrides without declaring Woo support.</li>\n<li>Using unsupported-theme fallback as if it were the normal integration path.</li>\n<li>Calling <code>is_shop()</code> in the body of <code>functions.php</code>.</li>\n<li>Replacing <code>wc_product_class()</code> with plain <code>post_class()</code>.</li>\n<li>Hardcoding <code>full</code> product images in archives.</li>\n<li>Declaring gallery slider/lightbox support without keyboard/focus testing.</li>\n</ul>\n<h2>References</h2>\n<ul>\n<li>Official documentation: <a href=\"https://developer.woocommerce.com/docs/theming/theme-development/classic-theme-developer-handbook/\">https://developer.woocommerce.com/docs/theming/theme-development/classic-theme-developer-handbook/</a></li>\n<li>Official documentation: <a href=\"https://developer.woocommerce.com/docs/theming/theme-development/template-structure/\">https://developer.woocommerce.com/docs/theming/theme-development/template-structure/</a></li>\n<li>Official documentation: <a href=\"https://developer.woocommerce.com/docs/theming/theme-development/image-sizes/\">https://developer.woocommerce.com/docs/theming/theme-development/image-sizes/</a></li>\n<li>Official documentation: <a href=\"https://developer.woocommerce.com/docs/theming/theme-development/conditional-tags/\">https://developer.woocommerce.com/docs/theming/theme-development/conditional-tags/</a></li>\n<li>Verified source paths:\n<ul>\n<li><code>wp-content/plugins/woocommerce/woocommerce.php</code></li>\n<li><code>wp-content/plugins/woocommerce/includes/class-wc-template-loader.php</code></li>\n<li><code>wp-content/plugins/woocommerce/includes/wc-conditional-functions.php</code></li>\n<li><code>wp-content/plugins/woocommerce/includes/wc-core-functions.php</code></li>\n<li><code>wp-content/plugins/woocommerce/includes/wc-template-functions.php</code></li>\n<li><code>wp-content/plugins/woocommerce/includes/wc-template-hooks.php</code></li>\n<li><code>wp-content/plugins/woocommerce/templates/global/wrapper-start.php</code></li>\n<li><code>wp-content/plugins/woocommerce/templates/global/wrapper-end.php</code></li>\n</ul>\n</li>\n</ul>\n","files":[{"path":"SKILL.md","sizeBytes":9264,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-09-16T14:57:49.653624Z","sha256":"D503B411829C85CA2DC53669CDE8671360E7A94B96667C5911A83885D79C18EC","sizeBytes":3275},"review":null,"source":{"repositoryUrl":"https://github.com/Lonsdale201/wp-agent-skills","path":"theme-development/classic-woocommerce-theme-support","license":"MIT","commit":"9025fda280d15da3e2ba376a66940e75bd45f3ce","subtreeSha":"0CC5E54AFDE875BA65197EE0E9EF34A7B4722986C09C5F429FA0CF0F29C6B6E0","lastSyncedAt":"2026-11-17T00:39:45.243627Z"},"reviewedAt":"2026-09-16T15:17:08.282566Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/Lonsdale201/wp-agent-skills/tree/main/theme-development/classic-woocommerce-theme-support"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install lonsdale201-wp-agent-skills@llmmart"},{"target":"git","command":"git clone https://github.com/Lonsdale201/wp-agent-skills.git"}]}