This PHP code enables you to add custom text before and after your products on all WooCommerce category archive pages.
The input field is added to all Edit Category screens for all product categories enabling easy addition of unique custom content on all product category pages using WooCommerce.
Demo Video
Shows you how to add custom text below your product category loop on WooCommerce product category archives.
Works in any theme. Tested using the 2020 default theme for WordPress and the Genesis Sample child theme by StudioPress.
Installation Steps
There’s 2 steps :
- # Copy & paste the PHP code from the functions.php file to the end of your child themes functions file.
- # Import the acf.json file using the Custom Field > Import settings added once you install the ACF ( Advanced Custom Fields ) plugin ( free or premium version )
Shop Loop Hooks
You can change the shop loop hooks to control where your custom field content displays on archive pages.
woocommerce_before_shop_loop_item
woocommerce_before_shop_loop_item_title
woocommerce_shop_loop_item_title
woocommerce_after_shop_loop_item_title
woocommerce_after_shop_loop_item
Archive Page Hooks Outside Shop Loop
You can change the hooks to control where your custom field content displays on archive pages outside your shop loop.
woocommerce_before_main_content
woocommerce_archive_description
woocommerce_before_shop_loop
woocommerce_after_shop_loop
woocommerce_after_main_content