the problem I’m having is quite weird, I have a couple simple get_field and update_field functions for retrieving and storing reference numbers. Unfortunately they seem to only work on the initial load of a page, so only the first time the page is loaded will it get the numbers from the fields and therefore display the proper data, after that the get_field function doesn’t retrieve anything so none of the data will display. I’ve tested this with update_field as well and nothing.
I’ve used ACF extensively in the past and I’m almost positive I’m not missing something. The site is in it’s infancy, not many plugins and nothing really to get in the way. Is it possible that the amount of pages on this site and therefore the amount of entries in postmeta is messing it up? There are upwards of 11k pages.
Nope doesn’t look like that’s the issue, the $post->ID stays the same the whole time. There’s very little happening on this page, like I said I’m just starting to set everything up, so all it has to do right now is find these fields from ACF and use that to display the proper data nothing else. Not to mention that specifying the post number at the end of the get_field() function also doesn’t help.
Ok so here’s the deal from the top. I have a large amount of static pages 11,000+ on each one there is a function that is supposed to save a few random reference numbers in ACF fields which will be used to pull data from the database.
There’s a bunch more to it but it’s not particularly relevant because even the basic stuff is not working properly.
For the purpose of fixing this problem let’s say I have 2 function on the page only, which is basically the case at this point.
update_field('reference_number', 92); $number = get_field('reference_number'); echo $number;
when I initially load one of the pages it will display correctly 92. If I immediately refresh the page the 92 goes away as if the field no longer exists, and I can never get it back. Also if I change the update_field() to enter a different number it will never change the number after that initial page load including if I check the actual entry in the postmeta table in the database.
Additionally everything is there and looks correct when I check the postmeta table in the database.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2019 Advanced Custom Fields. Subscribe