要在更新wordpress帖子时更新高级自定义字段

时间:2018-09-06 07:53:15

标签: wordpress advanced-custom-fields

我想在更新wordpress帖子时更新“高级自定义”字段。我为此使用了下面的代码,但update_field不起作用吗?

function check_values($post_ID, $post_after, $post_before)
{

 //File Unzip 
             WP_Filesystem();
             $destination = wp_upload_dir();
             $destination_path = $destination['path'];
             $unzipfile = unzip_file( $destination_path.'/'XML.zip', $destination_path);
                //Update Advanced Custom Field

              $field_key = "field_599d2d288e37c";
              $value = $destination_path;
              update_field( $field_key, $value, $post_ID );
            }

  add_action( 'post_updated', 'check_values', 10, 3 ); //don't forget the last argument to allow all three arguments of the function

0 个答案:

没有答案