Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 );
    }
share|improve this question
    
where are you using this code? –  Hameedullah Khan Jul 7 '11 at 5:56
    
the top of content-pt-album.php, pt being post type. Its modeled after twentyeleven. –  mattrepublic Jul 7 '11 at 13:11
add comment

1 Answer

up vote 1 down vote accepted

It depends on where you're using this. Is global $post giving you the specific post that you want to update? Your Wordpress update post code looks right to me, but is the if-statement valid, and is $post->ID yielding the correct int?

share|improve this answer
    
Yes, $post and $post->ID are producing the right outputs. :) –  mattrepublic Jul 24 '11 at 12:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.