Hi Guys, I’m trying to insert a custom field at the end of my shop page on Woocommerce. I’ve edited the archive-product.php file to include the field name, but it won’t display. If I replace the code with “test text” this does display. Any ideas?
<?php the_field('after-shop-text'); ?>
That doesn’t show, but:
Could you please make sure that you added the code inside The Loop? The issue you have mostly occurred because you were trying to execute the the_field() function outside of The Loop. To fix it, you need to pass the post/page ID as the second parameter to the get_field() function like this:
Where “99” is the post/page ID where the custom field is assigned. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/get_field/.
I hope this helps 🙂
Yes I suspect it may be outside of the loop then. I’ll try what you’ve mentioned. Thanks!!!
Perfect, thanks James. I placed the following code within the end of the loop and it has shown the field
$value = get_field( "after-shop-text", 8 );