AdvancedCustomFields / AdvancedCustomFields/acf
Does save_post work to update a field in a block?
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 945
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
I'm having a problem with save_post and updating an ACF field in a Gutenberg block. I have a field called 'youtube_title' and need to a add some text in a field when a post is being saved. I tried to do the following:
update_field('youtube_title', 'testvbv', $post_id);
The field doesn't get updated when saving. I then added a text box called 'test' and have it shown at the bottom of the editor. When I save a post, text does get added to the field.
update_field('test', 'testvbv', $post_id);
Any idea on how to add text to field inside a Gutenberg block?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the save_post hook and the update_field calls shown in the issue, then compare the youtube_title field's Gutenberg block configuration with the working test field. Done means identifying why the block field is not updated during post save and confirming that youtube_title receives the intended text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- content
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100