wp_update_post() example… how to update the_content in a textarea?
Question
I am using the below function to update the post meta from the front end. How can I add add best a textarea that updates the_content()
using wp_update_post()
?
if ( isset( $_POST['albums'] ) && wp_verify_nonce($_POST['albums'],'update_albums_postmeta') )
{ //if nonce check succeeds.
global $post;
$postid = $post->ID;
$data = $_POST['priceone'];
update_post_meta($postid,'_releasedate',$data);
$data = $_POST['pricetwo'];
update_post_meta($postid,'_amazonlink',$data);
}
–
Edit:
So this snippet is posting changes to the database, however when the page refreshes on-submit the old the_content()
is being shown. The post must manually be refreshed to see the changes.
Is my snippet malformed?
if ( isset( $_POST['drw_inventory'] ) && wp_verify_nonce($_POST['drw_inventory'],'update_drw_postmeta') )
{ //if nonce check succeeds.
global $post;
$data_content = $_POST['description'];
$my_post = array();
$my_post['ID'] = $post->ID;
$my_post['post_content'] = $data_content;
wp_update_post( $my_post );
}
0
wp-update-post
3 years
2020-04-07T00:51:03-05:00
2020-04-07T00:51:03-05:00 0 Answers
108 views
0
Leave an answer