Activity Stream
48,167 MEMBERS
61249 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 2 of 2
  1.     
    #1
    Member

    Default Wordpress, Category function Help..

    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...
    Mr.Mirchi Reviewed by Mr.Mirchi on . Wordpress, Category function Help.. 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 function add_category_automatically($post_ID) { global $wpdb,$post; $post_title = get_the_title(); if (stripos($post_title, Rating: 5
    Nothing for now -_-

  2.   Sponsored Links

  3.     
    #2
    Member
    You need to use http://codex.wordpress.org/Function_...t_object_terms

    then concat the old and new category arrays together before using set_object_terms.

    ---------- Post added at 12:44 PM ---------- Previous post was at 12:44 PM ----------

    You need to use http://codex.wordpress.org/Function_...t_object_terms

    then concat the old and new category arrays together before using set_object_terms.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need some function on wordpress site
    By ILHFFS in forum Wordpress
    Replies: 1
    Last Post: 8th Oct 2012, 02:15 PM
  2. Wordpress Category Tree View
    By downfreak in forum Wordpress
    Replies: 7
    Last Post: 13th Aug 2012, 02:46 PM
  3. Add pictures to category wordpress
    By coolro in forum Wordpress
    Replies: 0
    Last Post: 22nd Apr 2012, 06:34 PM
  4. Category list in header wordpress
    By samipk in forum Technical Help Desk Support
    Replies: 6
    Last Post: 9th Jun 2011, 04:47 AM
  5. Wordpress Category Help
    By BlaZe in forum Wordpress
    Replies: 0
    Last Post: 4th Dec 2009, 03:30 PM

Tags for this Thread

BE SOCIAL