basically... i already published the post with a category,, and now if the keyword matches a category , i want to add that category too.. and not replace the old category...i found this code on net, and edited a little bit... but it replaces the category,,, how to add the new category along with the old category .. ie concatenate???
old code
Thanx...
old code
Code:
function add_category_automatically($post_ID) {
global $wpdb,$post;
$post_title = get_the_title();
if (stripos($post_title, '2012')!==false) {
$cat = array(6);
wp_set_object_terms($post_ID, $cat, 'category');
}
}
add_action('publish_post', 'add_category_automatically');
Last edited: