Wordpress, Category function Help..

Status
Not open for further replies.

Mr.Mirchi

Active Member
544
2011
86
0
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
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');
Thanx...
 
Last edited:
1 comment
Status
Not open for further replies.
Back
Top