我这里的代码包括update_post_meta
使它在单击我的按钮时工作,尽管我没有找到如何防止update_post_meta
因为我在某个页面上有此按钮,所以无法刷新/访问每个页面。
代码如下:
<form action="" method="post">
<input type="submit" value="Test" id="submit">
<?php
$post = array(
\'post_title\' => $column1,
\'post_status\' => \'draft\',
\'post_type\' => \'bedrijf\'
);
$thisid = wp_insert_post ( $post, true);
if(!isset($_POST[\'submit\'])){
if ( is_wp_error($thisid) ) {
return get_error_codes();
}
}else{
wp_insert_post($thisid);
update_post_meta( $thisid, \'field_1223ewedwd3123\', $column2);
}
?>
</form>