- This topic has 9 replies, 3 voices, and was last updated 4 years, 3 months ago by David.
-
AuthorPosts
-
December 19, 2019 at 2:09 am #1108575FunkyCss
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 .
December 19, 2019 at 9:58 am #1109014TomLead DeveloperLead DeveloperHi there,
I’m not too sure what you mean – you should be able to hook anything into your site, regardless of the page.
Have you checked out the Hook Element?: https://docs.generatepress.com/article/hooks-element-overview/
In the Display Rules you can include/exclude pages, products etc..
Let me know 🙂
December 20, 2019 at 1:05 am #1109459FunkyCssTom 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 !
December 20, 2019 at 3:21 am #1109537FunkyCssI would apreciate if there is any tip on how to do this one
December 20, 2019 at 6:03 am #1109638DavidStaffCustomer SupportHi 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?
December 20, 2019 at 6:22 am #1109655FunkyCssHi David once again ! I did not think about shortcodes actually ! How is possible to call custom fields with short codes ?
December 20, 2019 at 6:38 am #1109691DavidStaffCustomer SupportSorry I thought you were Hooking ACF fields to be displayed in the Woo templates.
ACF has its own shortcakes:
December 20, 2019 at 6:53 am #1109830FunkyCssYeah maybe this is the only solution , a combo of this – > https://stackoverflow.com/questions/50672469/add-a-custom-field-variable-acf-to-a-custom-woocommerce-shortcode
and the acf shortcodes maybe , i will give it a try
December 20, 2019 at 6:55 am #1109832FunkyCssActually 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 .
December 20, 2019 at 7:13 am #1109849DavidStaffCustomer SupportYeah Gutenberg does ‘mix’ things up a bit. You may want to look into ACF Blocks as well:
-
AuthorPosts
- You must be logged in to reply to this topic.