Add a WooCommerce missing action hook with shortcode in Beaver Builder

Some themes or plugins remove native action hooks in WordPress / WooCommerce, however you can add them back in the layout with another action hook or shortcode insertion.

Beaver Builder is missing some WooCommerce action hooks one such one is woocommerce_before_shop_loop_item_title , you can add that back to the WooCommerce loop by doing a custom layout in a Posts module or PowerPack Product Grid.

Add the hook back by creating a shortcode in your functions.php file:

add_shortcode( 'woohook', 'woo_missing_hook' );
/**
 * Add a missing hook with shortcode
 * @since 1.0.0
 */

function woo_missing_hook() {
ob_start();
    do_action( 'woocommerce_before_shop_loop_item_title' );
return ob_get_clean();
}

Now in your custom layout add in the [woohook] shortcode to add the action hook back in.

2 comments

  • Thank you for sharing your insights on adding a WooCommerce missing action hook with a shortcode in Beaver Builder. I loved how you broke down the steps involved in adding the missing action hook and how you incorporated a shortcode to display the add-to-cart button. Your instructions were clear and concise, making it easy for readers to follow along and implement the solution on their own websites. Do you anticipate any issues with the solution breaking or becoming outdated as these platforms continue to evolve?

  • You can add this back into the Woo Commerce loop by customizing the layout in the Posts module or the Power pack product grid. Now add the [woo hook] short code to re-add the action hook to your custom layout.

Leave your comment