I have created a loop to show some products on my wordpress site and they seem to be working fine they reel out the products however if I place one of custom fields after the loop it doesn’t show. I know its not an issue with the custom field itself as it works fine if I put it above the loop. Does anyone know where I could be going wrong?
Here is my code:
Thanks
You are calling
setup_postdata()
within your loops, therefore overwriting the$post
object.When you are calling
the_field('monoblock_valves_text');
after the foreach loop, it’s trying to get that custom field out of the last post of the loop, while it clearly needs to get it from the actual post/page showing.You need to store the old $post object before the loop, and restore it after the loop, as such: