admin管理员组文章数量:1430637
I am trying to write a function to copy the value of an imported custom field (postalCode) to another custom field (wpcf-adres) when the post is saved or created. But i cannot get it to work, so there must be something not right in the code? Thanks for any advice or solution given!
function sync_postalcode( $post_id ) {
// GET Postal code FROM OTHER FIELD
$postcode = get_post_meta( $post_id, 'postalCode', true);
// UPDATE Postalcode IN adres FIELD
update_post_meta( $post_id, 'wpcf-adres', $postcode );
}
add_action( 'save_post', 'sync_postalcode' );
本文标签: save postupdate a custom field with the value of another existing custom field
版权声明:本文标题:save post - update a custom field with the value of another existing custom field 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745549853a2662888.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论