Post edit via script creates unwanted results.
-
The following code is supposed to remove a specified category from a post and update the publish date of the post. This part works, however the script seems to be replacing
< br />
tags with< br >
tags.Anyone have an idea why or how to prevent that?
if ($post_id_to_update) { $args=''; $old_terms = wp_get_post_terms( $post_id_to_update , $taxonomy, $args); $new_terms = array(); if ($old_terms) { foreach ( $old_terms as $old_term ) { if ($old_term->term_id != $term->term_id) { $new_terms[]=$old_term->name; } } } wp_set_post_terms( $post_id_to_update, $new_terms, $taxonomy, $return ); } $my_post = array(); $my_post['ID'] = $post_id_to_update; $my_post['post_date'] = date("Y-m-d H:i:s"); $my_post['post_date_gmt'] = gmdate("Y-m-d H:i:s"); wp_update_post( $my_post ); $wpdb->flush();
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Post edit via script creates unwanted results.’ is closed to new replies.