Remove all the old tags in post using code.
-
Hi, I been using one plugin that assigns tags to posts containing specific text strings comparing with external file when I press de PUBLISH button. When I make changes from an old post and push UPDATE the new text append new tags to the post. And the old ones still on it. I need to know how modify this code to make posible the erase of old tags before to put the new ones. I read all information in codex.wordpress.org and nothing help me. I looking on the web and only get this http://wordpress.stackexchange.com/questions/49248/remove-tags-from-posts-in-php and this url http://stackoverflow.com/questions/3356380/wordpress-delete-all-tags-by-post-id but when I use this codes nothing happend or just get an error massage.
-
add_action( 'save_post', 'jpl_docs_autotag' ); function jpl_docs_autotag($post_id) { $post = get_post($post_id); if ( intval($post->ID) > 0 ) { // HERE IS WHERE I PUT THE CODE THAT I´VE TRIED $options = get_option( 'docs_autotags' ); if ( count($options) > 0 ) { foreach ( $options as $pattern => $tags ) { if ( strpos($post->post_content, $pattern) ) wp_set_post_tags( $post->ID, $tags, TRUE ); // TRUE means append } } } }
Thanks
-
- The topic ‘Remove all the old tags in post using code.’ is closed to new replies.