Site logo

Archived topic

Gutenenberg Pages Woocomerce Block Hook

9 replies · Started by FunkyCss on December 19, 2019

Viewing posts 1–10 of 10

Hi , Can we use a hook or filter on simple pages to show ACF .

So i have created for each woocomerce product a custom field that is a subtitle . and i can show them on woo pages with a simple hook .

But is this possible or any hook available for not woocomerce pages and simple pages . i have to notice that pages are created with woocomerce short code inside gutenberg editor .

Tom thank you for your reply ! I have tried Hook Elements and its one of the greatest things i have ever used! has helped me a million of times on my projects and clients like it !

What i say is , i have created a field with ACF on Woocomerce products , its a like a subtitle .

With this php code

add_action( 'woocommerce_single_product_summary', 'display_acf_field_under_title', 6 );
function display_acf_field_under_title() {
echo '<span class="woo-subtitle">' . get_field('subtitle_'). '</span>';
}

I can show them on woo pages .

And with this one

remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
add_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 11 );

I transfer Product name above Image . THis is easy .

But i have a page created with Gutenberg and i dont know how to access and make this changes there .

I mean i use Woocomerce Gutenberg blocks to show my categories in the page , but i cant show the ACF fields !

I would apreciate if there is any tip on how to do this one

Hi there,

unfortunately the Woo Guteneberg Blocks don't use the core woo templates so don't contain any hooks.

Have you tried using the Woo Shortcodes instead?

Hi David once again ! I did not think about shortcodes actually ! How is possible to call custom fields with short codes ?

Actually the best practice for someone is to create a custom woo archive template where you can easily work on it , but now is been maded with gutenberg so i have to try it with what i have , but my advice for someone that has the same is go with custom php template .

This archived topic is closed to new replies.