<?php
/*
Plugin Name: Autosave Title As Tags
Plugin URI: http://fusedthought.com/downloads/autosave-post-title-as-tags-wordpress-plugin/
Description: Automatically use the words in your post title as a Tag.
Author: Gerald Yeo
Author URI: http://fusedthought.com
Version: 0.3
*/
function SaveTitleAsTag($post_ID) {
$gpt = get_post($post_ID);
$posttitle = $gpt->post_title;
$posttitle = strtolower($posttitle);
if(get_the_tags($post_ID)){
foreach(get_the_tags($post_ID) as $tag) {
$tag_name = $tag->name;
$tag_name = strtolower($tag_name);
$posttitle = str_replace($tag_name, "", $posttitle);
}
}
$splittotags = explode(",", $posttitle);
$lastarray = end($splittotags);
foreach ($splittotags as $atag){
if ($atag == $lastarray){
$atag = explode(" ", $atag);
foreach ($atag as $satag){
$satag = str_replace(" ", "", $satag);
if($satag !=NULL){
wp_set_object_terms($post_ID, $satag, 'post_tag', true );
}
}
}else{
if($atag !=NULL){
wp_set_object_terms($post_ID, $atag, 'post_tag', true );
}
}
}
//update_post_meta($post_ID, 'getthetag', $gettags);
}
add_action('save_post', 'SaveTitleAsTag');
?>
Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.
Contact us