Quantcast
Channel: Toolset » All Posts
Viewing all articles
Browse latest Browse all 20145

Updating a custom post field using the wp_update_post function

$
0
0

I have an existing function which works correctly to update the post status of a parent post (slug='sell-list') when a child CRED action is completed. The code is;

//Change status of parent post when 'Place Order' button is pressed
add_action('cred_submit_complete_1298', 'change_parent_status', 10, 2);
function change_parent_status($post_id){
	$sell_list_id = get_post_meta($post_id, '_wpcf_belongs_sell-list_id', true);
    if (isset($sell_list_id)) {
        wp_update_post(array('ID' => $sell_list_id, 'post_status' => 'private'));
    }
}

I also want to update the value of a single line custom field called 'invoice-status' for the same post type 'sell-list'. Can I add this to the same wp_update_post code line above? If yes, could you show me the correct format to use please.

Regards

Robert


Viewing all articles
Browse latest Browse all 20145

Trending Articles