wp_update_post not working
-
I have a relatively simple custom post that I created with Pods (which I think is terrific). I am trying to programmatically update a post, which is something I’ve not done before. I’ve looked at quite a few examples, and it seems straightforward, but my code is not working. It is making the call to wp_update_post. I am also not getting any errors. I’m wondering if there is a setting or something else that is preventing the post from updating. Here’s the code I have:
$donor = new WP_Query( $args ); $found = $donor->post_count; if ( $found >= 1 ) { $weight = 188; $age = 22; while ( $donor->have_posts() ) { $donor->the_post(); $update_post = array( 'ID' => get_the_id(), 'weight' => $weight, 'age' => $age, ); $ustatus = wp_update_post( $update_post, true ); if (is_wp_error($ustatus)) { echo 'Error '. $ustatus->get_error_code() .': '. $ustatus->get_error_message(); } } }
Thank you for any help!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘wp_update_post not working’ is closed to new replies.