WordPress action hook

woocommerce_before_main_content

Defined by WooCommerce and fired by 58 plugins in total, running on 7.1M+ sites between them.

“Hook: woocommerce_before_main_content”

How to use woocommerce_before_main_content

It's an action: your callback runs at that point. Nothing needs to be returned. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_action( 'woocommerce_before_main_content', function() {
	// Your code runs here.
}, 10, 1 );

Argument names come from WooCommerce's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

58 plugins that fire woocommerce_before_main_content

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. WooCommerce icon WooCommerce7+ million installs do_action( 'woocommerce_before_main_content' ) src/Blocks/BlockTypes/ClassicTemplate.php:258
  2. User Profile Builder icon User Profile Builder40,000+ installs do_action( 'woocommerce_before_main_content' ) features/content-restriction/templates/archive-product.php:19
  3. Dokan: AI Powered WooCommerce Multivendor Marketplace Solution icon Dokan: AI Powered WooCommerce Multivendor Marketplace Solution30,000+ installs do_action( 'woocommerce_before_main_content' ) templates/store.php:24
  4. Genesis Connect for WooCommerce icon Genesis Connect for WooCommerce10,000+ installs do_action( 'woocommerce_before_main_content' ) lib/template-loader.php:248
  5. Paid Membership Subscriptions icon Paid Membership Subscriptions10,000+ installs do_action( 'woocommerce_before_main_content' ) extend/woocommerce/templates/archive-product.php:19
  6. Passster icon Passster10,000+ installs do_action( 'woocommerce_before_main_content' ) inc/templates/woo-category-protected.php:19
  7. King Addons for Elementor icon King Addons for Elementor10,000+ installs do_action( 'woocommerce_before_main_content' ) includes/extensions/Woo_Builder/templates/cart.php:24
  8. eCommerce Product Catalog icon eCommerce Product Catalog7,000+ installs do_action( 'woocommerce_before_main_content' ) templates/templates-woo.php:188
  9. Ibtana icon Ibtana5,000+ installs do_action( 'woocommerce_before_main_content' ) inc/class-public.php:82
  10. Product Table for WooCommerce icon Product Table for WooCommerce5,000+ installs do_action( 'woocommerce_before_main_content' ) templates/store.php:22
  11. Return Refund and Exchange For WooCommerce icon Return Refund and Exchange For WooCommerce4,000+ installs do_action( 'woocommerce_before_main_content' ) public/partials/wps-rma-refund-request-form.php:23
  12. Ultimate Store Kit icon Ultimate Store Kit3,000+ installs do_action( 'woocommerce_before_main_content' ) includes/builder/templates/woocommerce/login.php:31
  13. WC Vendors icon WC Vendors3,000+ installs do_action( 'woocommerce_before_main_content' ) templates/front/vendor-shop.php:40
  14. The Pack Elementor addon icon The Pack Elementor addon2,000+ installs do_action( 'woocommerce_before_main_content' ) includes/widgets/woocommerce/woo-archive-product/view.php:3
  15. WC Builder icon WC Builder1,000+ installs do_action( 'woocommerce_before_main_content' ) woo-templates/archive-product.php:33
  16. Product Layouts for WooCommerce icon Product Layouts for WooCommerce1,000+ installs do_action( 'woocommerce_before_main_content' ) Includes/Woocommerce/custom-product-category.php:20
  17. Product Catalog Simple icon Product Catalog Simple1,000+ installs do_action( 'woocommerce_before_main_content' ) core/templates/templates-woo.php:188
  18. Smart Search & Product Filter for WooCommerce icon Smart Search & Product Filter for WooCommerce900+ installs do_action( 'woocommerce_before_main_content' ) templates/smart-navigation.php:31
  19. StylePress for Elementor icon StylePress for Elementor600+ installs do_action( 'woocommerce_before_main_content' ) extensions/woocommerce/templates/archive-product.php:35
  20. StoreBuild icon StoreBuild400+ installs do_action( 'woocommerce_before_main_content' ) public/woocommerce/archive-product.php:29
  21. Noah Shop Builder for WooCommerce icon Noah Shop Builder for WooCommerce400+ installs do_action( 'woocommerce_before_main_content' ) templates/canvas-theme.php:32
  22. Track Orders for WooCommerce icon Track Orders for WooCommerce200+ installs do_action( 'woocommerce_before_main_content' ) template/wps-guest-track-order-page.php:26
  23. Search, Filters & Merchandising for WooCommerce icon Search, Filters & Merchandising for WooCommerce200+ installs do_action( 'woocommerce_before_main_content' ) public/wcis_product_cat.php:52
  24. Filter Plus icon Filter Plus100+ installs do_action( 'woocommerce_before_main_content' ) templates/woo-filter/category-layout.php:22
  25. Shopready icon Shopready100+ installs do_action( 'woocommerce_before_main_content' ) src/extension/templates/tpl/archive-product.php:29
  26. WPCafe Multivendor Restaurant Addon for Dokan icon WPCafe Multivendor Restaurant Addon for Dokan100+ installs do_action( 'woocommerce_before_main_content' ) templates/store-front/menu-style/store-header.php:23
  27. AMP WooCommerce icon AMP WooCommerce90+ installs do_action( 'woocommerce_before_main_content' ) templates/layouts/single.php:4
  28. Product Page Customizer for WooCommerce icon Product Page Customizer for WooCommerce60+ installs do_action( 'woocommerce_before_main_content' ) frontend/templates/builder-single-product-block-theme.php:39
  29. CelerSearch icon CelerSearch30+ installs do_action( 'woocommerce_before_main_content' ) templates/views/shop-view.php:22
  30. Educat Elementor LMS Addon icon Educat Elementor LMS Addon20+ installs do_action( 'woocommerce_before_main_content' ) includes/widgets/woocommerce/woo-archive-product/view.php:3
  31. Luma Product Fields icon Luma Product Fields10+ installs do_action( 'woocommerce_before_main_content' ) templates/taxonomy-product-archive.php:125
  32. Flowbox icon Flowbox10+ installs do_action( 'woocommerce_before_main_content' ) template/woocommerce/single-product.php:31
  33. Product category and page relation icon Product category and page relation10+ installs do_action( 'woocommerce_before_main_content' ) woocommerce/archive-product.php:79
  34. Yay Wholesale B2B for WooCommerce icon Yay Wholesale B2B for WooCommerce10+ installs do_action( 'woocommerce_before_main_content' ) includes/Engine/Compatibles/Barn2WoocommerceProductTable/templates/product-table-shop.php:31
  35. Proshots For WooCommerce icon Proshots For WooCommerce10+ installs do_action( 'woocommerce_before_main_content' ) templates/archive-product.php:29
  36. Formdev icon Formdev10+ installs do_action( 'woocommerce_before_main_content' ) templates/archive-product.php:13
  37. BannerWoo icon BannerWoo10+ installs do_action( 'woocommerce_before_main_content' ) includes/banner-type.php:12
  38. NoorPDP icon NoorPDP10+ installs do_action( 'woocommerce_before_main_content' ) templates/single-product-layout.php:17
  39. Product Bundles for WooCommerce icon Product Bundles for WooCommerce10+ installs do_action( 'woocommerce_before_main_content' ) templates/landing.php:18
  40. WebToffee Universal Commerce Protocol Enabler for Woocommerce icon WebToffee Universal Commerce Protocol Enabler for Woocommerce10+ installs do_action( 'woocommerce_before_main_content' ) includes/modules/identity-linking/class-webtoffee-ucp-enabler-for-woocommerce-identity-linking.php:2069
  41. Lock My WooCommerce icon Lock My WooCommerce10+ installs do_action( 'woocommerce_before_main_content' ) template/woocommerce-lock.php:14
  42. SpeedSearch icon SpeedSearchFewer than 10 installs do_action( 'woocommerce_before_main_content' ) src/integrations/themes/flatsome/templates/woocommerce/archive-product.php:39
  43. WEBD Woo Event Bookings icon WEBD Woo Event BookingsFewer than 10 installs do_action( 'woocommerce_before_main_content' ) templates/archive-product.php:59
  44. Yay Bulk Order for WooCommerce icon Yay Bulk Order for WooCommerceFewer than 10 installs do_action( 'woocommerce_before_main_content' ) includes/Engines/Compatibles/YayWholesale/templates/product-table-shop.php:29
  45. GrowthLab Bundle Builder for WooCommerce icon GrowthLab Bundle Builder for WooCommerceFewer than 10 installs do_action( 'woocommerce_before_main_content' ) templates/single-glbbwc_bundle.php:23
  46. Arshida Toolkit for WooCommerce icon Arshida Toolkit for WooCommerceFewer than 10 installs do_action( 'woocommerce_before_main_content' ) src/Modules/QuickOrderBySku/templates/single-product.php:25
  47. AWSA Quick Buy for Woocommerce icon AWSA Quick Buy for WoocommerceFewer than 10 installs do_action( 'woocommerce_before_main_content' ) templates/single-product-template.php:22
  48. Multiconnect Salsify icon Multiconnect SalsifyFewer than 10 installs do_action( 'woocommerce_before_main_content' ) templates/single-product/salsify-woo-1-fse.php:20
  49. Polanger Dating for WordPress icon Polanger Dating for WordPressFewer than 10 installs do_action( 'woocommerce_before_main_content' ) templates/integrations/woocommerce/archive-product.php:23
  50. Flx Modernize icon Flx ModernizeFewer than 10 installs do_action( 'woocommerce_before_main_content' ) includes/Flatsome/FlatsomeParts.php:478
  51. CardGrid for WooCommerce icon CardGrid for WooCommerceFewer than 10 installs do_action( 'woocommerce_before_main_content' ) templates/engine-wrapper.php:43
  52. Pablo MeasureCart icon Pablo MeasureCartFewer than 10 installs do_action( 'woocommerce_before_main_content' ) templates/archive-product.php:19
  53. OneTrace for WooCommerce icon OneTrace for WooCommerceFewer than 10 installs do_action( 'woocommerce_before_main_content' ) templates/search-results.php:12
  54. Custom Shop Filter by Webnotics icon Custom Shop Filter by WebnoticsFewer than 10 installs do_action( 'woocommerce_before_main_content' ) public/shortcodes/archive-product.php:106
  55. SingleGrid PDP Builder for WooCommerce icon SingleGrid PDP Builder for WooCommerceFewer than 10 installs do_action( 'woocommerce_before_main_content' ) includes/templates/single-product-template.php:37
  56. Xcodesol Shop Builder icon Xcodesol Shop BuilderFewer than 10 installs do_action( 'woocommerce_before_main_content' ) renderers/product-archive.php:28
  57. Asuka Product Designer icon Asuka Product DesignerFewer than 10 installs do_action( 'woocommerce_before_main_content' ) templates/frontend/woocommerce-product-full-width.php:24
  58. Whalet Payment icon Whalet PaymentFewer than 10 installs do_action( 'woocommerce_before_main_content' ) templates/whalet-checkout.php:65

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.