Why don’t you wrap it in post save_post and post_publish hooks?
You have examples here: http://codex.wordpress.org/Function_Reference/add_action
How to do it:
Add this to your functions.php file:
function my_data_update () {
$company = get_field('company_name');
$address = get_field('address');
$city = get_field('city');
$post_code = get_field('post_code');
//etc etc...
}
add_action('publish_post', 'my_data_update');
add_action('save_post', 'my_data_update');
Related Posts:
- How to Test a Blog Post for Update vs. Publish Status — Unique
- add action only on post publish – not update
- How to prevent posts from being published too close to each other?
- Is it possible to Schedule Attachments in WordPress?
- Elegant way to include only published posts with get_objects_in_term()?
- WordPress plugin to publish to multiple remote WordPress blogs
- Post publish only hook?
- Publish pending article from front end with a button?
- How to add a “publish” link to the quick actions
- How to limit user to publish post per day and per role?
- How to batch update post content with custom post meta value
- When a user creates a post (pending), send a confirmation link that allows them to publish
- In what sequence are the hooks fired when a post is “published”?
- Restrict the Number of Posts an Author can Publish (over time)?
- Add javascript when post is published
- featuring old articles without messing up with the archive
- Publish posts only after the condition is met
- Hiding by default specific post status on backend list?
- Detect Post Type when publish_post is ran
- How can I display a specific user’s first published post?
- Does WordPress remove draft status automatically?
- What Can I Use To Add A Custom Button Between Publish button and Move To Trash?
- Prevent post from being published if no category selected
- Send email to user that his post has been rejected
- Limit number of posts a user can make per minute?
- How do I allow users to follow a post and then allow admins to email all users who have followed that post?
- Syndicated Posts when Updated Lose HTML tags
- Every possible way to get data (posts) from WordPress
- publish_post conflicts with save_post
- Notification to Admin or Author upon new post [duplicate]
- Post update RSS notification plugin
- What differences are there between a Privately Published post and a Draft post?
- How to run a function when post is edited or updated using publish post action?
- How can I create custom button in post.php
- How to rename “Publish” metabox title in post screen
- WordPress version 3.8 – Preview button not working for editor
- Create post for every user?
- Image Insert into posts and pages not working after 3.2.1 update
- count the total number of comments the user has received for his published posts
- Automatically Updating Publish Date Bug
- How can I schedule a PAGE to go live at a future date/time?
- How to give capability (publish contributors posts) to author role?
- Print a message if excerpt is empty after posts have been publish/update!
- check if wordpress is updating or publishing a post
- Check if checkbox is marked on publish/update post
- Decide user that can publish a post
- How to switch wordpress post status between publish and schedule in MySQL?
- Prevent scheduled post being published if date/time is past current date/time
- Calling Different Custom Post Timestamps in a table
- Can’t update old posts 3.5.2
- Copy post to separate database with “add_action(….)”
- transition_post_status hook doesn’t have any POST data when publish with Gutenberg [closed]
- How do I manage my users post before publish?
- do more action after I publish a post
- Assign published posts to another user automatically
- Display password protected posts to logged in users
- Stop wordpress from creating empty/null entries
- WordPress bulk category select when publishing post
- Posts Missing in Dashboard after update
- How can I tell if a post has been published at least once?
- Send email for pending post
- Post: how to set created date after post has been published [closed]
- Add delay to publish post
- Publish a Silent Post without updating Feed
- How can my plugin display a populated new post window
- MySQL: Possible to replace all of wp_posts.post_content(id#) via UPDATE + REPLACE + SELECT?
- How to set a Post’s default visibility to ‘Private’ in Gutenberg?
- WordPress doesn’t save or publish new posts
- Hook when post is set from published to draft?
- Send email to user when I publish a new post
- My posts are getting to Auto draft when I try to Publish
- How to publish a post if condition is met?
- WordPress get tags in “publish_post” hook
- How publish post from pending status
- post is not showing more than 3949 words
- Bulk Post update_post_meta
- Create blog post from external source and set publication date
- update post category in a new table on frequent change of category
- I want to send push notification just after publish a new post
- How to handle a post before publishing?
- Return All Post from publish to draft [duplicate]
- I am creating a front end dashboard where I need to show all the posts by the current user. So, I need to show posts in publish
- Action while post is being published
- How can add custom commands in post-new.php in wordpress
- WordPress Post Updating is Not Working
- Setting Custom Sort Order of Posts within a Category
- Display post number not post ID number
- Check to see if specific loop has less than certain amount of posts
- Sticky post appears twice
- Editing the default page to show all posts, rather than most recent ones
- How to make a bilingual front-end post using the plugin WP User Frontend and Polylang or qTranslate?
- How to get subcategories from category slug?
- Conflict array_splice on loop and query in widget
- How come this loop is not working? [closed]
- A better code for no post format?
- how to put post customized in page
- how to print total number of posts filtered by category?
- Add a unique meta desciption
- Comment Authors of Post On Front Page
- Make a custom URL and link to custom Template