Support » Plugins and Hacks » How to update post cat before save_post (wp_set_post_categories only works once

  • Hey guys,

    I’m trying to update categories of a post based on input in custom fields but wp_set_post_categories only works when the post is first created.

    I tried update_post_meta but that goes into an infinite loop because it calls the save_post action again.

    Is there anyway I can update the post categories directly through wpdb UPDATE?

    Thanks for your help,

    Balthazar

    //this only works when post is first created!
    function save_post_boxes($postID){
    $new_cats = array();
    array_push($_POST[$field]);
    save_custom_field($postID, $field, $_POST[$field]);
    wp_set_post_categories($postID, $new_cats);
    }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to update post cat before save_post (wp_set_post_categories only works once’ is closed to new replies.