save post - update a custom field with the value of another existing custom field

I am trying to write a function to copy the value of an imported custom field (postalCode) to another custom field (wpcf

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' );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745549854a4632522.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信