update a post with wp_update_post
update a post with wp_update_post
update a post with wp_update_post
why wp_update_post cant update when value is empty?
how to transition to custom post status on post save
There’s a more elegant way of updating your posts using the global $wpdb. function rsc_unpublish_all_ads( $post_id, $post, $update ) { // select all ads other than the current one $args = array( ‘nopaging’ => true, ‘post__not_in’ => array($post_id), ‘post_type’ => ‘rsc-ads’, ‘post_status’ => ‘publish’, ‘fields’=>’ids’ ); $query = new WP_Query($args); $published_ads = $query->posts;//array of post … Read more
When User Meta amended update Title and Slug of Post programatically
Found Solution : If there is no data in the request_body, the we can also fetch it from the postID which is already we have. Changed Code: added condition if data not available, then get it from post id public static function saveDataInNotificationTable($ID,$request_body) { $post_data = json_decode($request_body); $tags = $post_data->tags; if($post_data == “” || $post_data … Read more
How to bulk edit image url in featured image and product description?
Allow Post Author to be 0 on Update
Try this: $jobsTerms = get_terms(‘jobtype’,array( ‘taxonomy’ => ‘jobtype’ )); foreach($jobsTerms as $term){ $checked = (has_term($term->slug, ‘jobtype’, $post->ID)) ? ‘checked=”checked”‘ : ”; echo “<label for=”term-” . $term->slug . “”>” . $term->name . “</label>”; echo “<input type=”checkbox” name=”term” . $term->slug . “” value=”” . $term->name . “” $checked />”; } Replace $post_id with whatever you need to … Read more
You can use wp_get_post_revisions. <?php // some logic here $post_id = wp_update_post(/* … */); $latest_revision = array_shift(wp_get_post_revisions($post_id)); if ($latest_revision) { // do stuff with the latest revision // $latest_revision->ID will contain the latest revision }