Skip to content
WJunction - Webmaster Forum

Wordpress, Category function Help..

Status
Not open for further replies.
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.

About the author

M
Active Member · Joined
544
Messages
86
Reactions
28
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom