';
echo '
Add Tags To Posts
';
if( !empty($_POST["attp_tags"]) && $_POST['attp_submit'] == 'attp_submit' ){
global $wpdb;
$tags=preg_split('/(\r\n|\r|\n)/',$_POST["attp_tags"]);
$sql="select ID,post_content,post_title from $wpdb->posts where post_type='post'";
$posts = $wpdb->get_results($sql,OBJECT);
foreach($posts as $post){
foreach($tags as $atag){
$id=$post->ID;
$title=$post->post_title;
$content= $post->post_content;
if(preg_match("/\b".preg_quote($atag)."\b/i",$title)){
wp_add_post_tags($id, $atag);
}elseif(preg_match("/\b".preg_quote($atag)."\b/i",$content)){
wp_add_post_tags($id, $atag);
}
}//end tags
}//end posts
echo '';
}
echo 'One Tag Per Line
';
echo "";
echo "" ;
}
?>