• 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)
  • Thread Starter john-michael

    (@john-michael-1)

    Update,

    The above code also removes flash object code, for example,

    This code,
    <object width="400" height="265"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="https://vimeo.com/moogaloop.swf?clip_id=10666627&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" /><embed src="https://vimeo.com/moogaloop.swf?clip_id=10666627&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="265"></embed></object><p><a href="https://vimeo.com/10666627">My Ballins Is Magnificent</a> from <a href="https://vimeo.com/drthil">Dan Thilman</a> on <a href="https://vimeo.com">Vimeo</a>.</p>

    Is changed to this after the script runs,
    <p><a href="https://vimeo.com/10666627">My Ballins Is Magnificent</a> from <a href="https://vimeo.com/drthil">Dan Thilman</a> on <a href="https://vimeo.com">Vimeo</a>.</p>

Viewing 1 replies (of 1 total)
  • The topic ‘Post edit via script creates unwanted results.’ is closed to new replies.