I cannot update a wp_postmeta field called 'alive_days' and making its value equal to zero, in wordpress. I have tried all the two following solutions but still not working:
- $alive_days='alive_days';$mypostid=$_REQUEST['pid'];
- global $wpdb;
- $wpdb->query("update $wpdb->wp_postmeta set meta_value==\\"$ziro\\" where post_id=\\"$mypostid\\" and meta_key=\\"$alive_days\\"");
The field value will not change after the execution.
Try This,
$ziro=0; $alive_days = 'alive_days'; $mypostid = $_REQUEST['pid'];
global $wpdb;
$wpdb->update(
'wp_postmeta',
array(
'meta_value' => $ziro,
'meta_key' => $alive_days
),
array( 'ID' => $mypostid )
);
More Informations enter link description here
尝试使用此代码
update_post_meta( $post_id,'alive_days', 0 );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.