Home › Forums › Backend Issues (wp-admin) › How to update postmeta with ACF? › Reply To: How to update postmeta with ACF?
I think I have to use update_field();
function update_acf_manually() {
var_dump('update_acf_manually');
$args = array(
'orderby' => array('ID' => 'ASC'),
'post_type' => 'member',
'posts_per_page' => '-1',
);
foreach (get_posts($args) as $post) {
$pm = get_post_meta($post->ID, 'join_date', true);
$Y = substr($pm, 0, 4);
$m = substr($pm, 4, 2);
$d = substr($pm, 6, 2);
if ($Y && $m && $d) {
var_dump("$Y-$m-$d");
$pm = "$Y-$m-$d";
update_field('join_date', $pm, $post->ID);
}
}
}
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.