shortocdes on woocommerce product pages for ACF
-
Hi there,
Hope you are doing well.
I discover a really powerfull plugin, Advanced Custom Field (ACF), but I am struggling to make it work because needs either php code (in functions.php) or shortcodes to display the content in the front-end.
I've chosen shortcodes because easier, but i am wondering where can I add them on product pages. It seems that there is only "text box" (see image below).Can someone help me? Either with shortcodes on product pages or even where to add my php line in the functions.php file? Looking like this:
<?php $icons = get_field( 'icons' ); ?>
<?php if ( $icons ) : ?>
<img src="<?php echo esc_url( $icons['url'] ); ?>" alt="<?php echo esc_attr( $icons['alt'] ); ?>" />
<?php endif; ?>Thanks a lot, and have a nice day!
Sofia -
oh really you can use shortcodes with acf, i didn't know!
i need to code something differently for lay theme. some shortcodes don't work because they rely on the "content" filter
https://developer.wordpress.org/reference/hooks/the_content/
but lay theme doesn't pass through its content through that filter
it might work if you're in the gridder and press +more → +shortcode and put the shortcode in there
-
Hi @arminunruh!
Thanks for the answer
Okay! On the gridder on my products pages, the +more → +shortcode does not appear unfortunately (on the other page it does appear), but i think as you said it is because of the content filter. But would be so great and easier if there was this button shortcode! Do you think you could announce it when you'll do that?
Would be magic 🔮Thanks a lot again,
Have a nice week
Sofia -
hi sophia!
ah yea the gridder doesn't exist on a product page
i wrote this down mmh not sure when i will have time!
-
@arminunruh
Hii!
thanks:)I ate a lot of tutorials and FINALLY managed to do something that worked.
I put here the magic link with all the explanation (short and simple by the way), maybe it is useful for someone til you install the shortcode tool on product page 💜Have a nice day!
https://wplake.org/blog/woocommerce-product-page-template-with-acf-fields/
-
ooh very nice! congratulations!
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"
This often solves issues you might run into
When you post:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it