There is a no wp_update_tags in WordPress codex.But we realize it through an indirect method.Accordingly, the function below; first, remove the tags related with post_ID and insert new tags.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// Coded by tankado at tankado dot com function wp_update_post_tags($post_ID, $tags) { global $wpdb; // Delete related tags from database $sql = "DELETE FROM wp_term_relationships "; $sql .= "WHERE wp_term_relationships.object_id = '$post_ID' "; $sql .= "AND wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id "; $sql .= "AND wp_term_taxonomy.taxonomy = 'post_tag'"; $wpdb->query( $sql ); // Insert new tags to database wp_set_post_tags($post_ID, $tags, false ); } |