I have made an ACF form to insert data into WP. I also have an offline dataset that I wrote a wp-cli script to bulk import as new posts. To fill in the acf fields I insert them using wp-cli post meta add <id> <field> <value>
Everything seems to be fine. If I go to the wp-admin edit form and open one of the posts all data is there.
However, I want to make a customized rendering of this data in the blog post page. So I use a function in functions.php based on one of my theme’s filter (tc_post_list_content of Customizr) to manipulate how the post list is rendered.
Unfortunately, trying to do:
$fields = get_fields(get_the_ID());
returns false. How can I overcome this problem?
I noticed that if I go to the web interface and edit one of the imported post entries, then (even without changing anything), I click the “Update” button and then go to my posts list page and reload, get_fields returns properly the fields for that entry.
indeed, for those coming here with the same problem, I set with wp-cli custom_field and _custom_field (the second setting it to each field’s ACF key value) via the wp add post meta and it worked like a charm.
Viewing 3 posts - 1 through 3 (of 3 total)
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