• Resolved AliMH

    (@alimh)


    I’m using wp_insert_post to add a new post to my post type, but i don’t know how to append my defined taxonomies to that post.
    i suspect wp_set_object_terms, if this is the function to add taxonomy please explain it more.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter AliMH

    (@alimh)

    Bump!!!

    $category_ids = array(23, 52, 81);
    wp_set_object_terms( $post_id, $category_ids, 'product_category');

    I believe, where
    $post_id relates to $post_id = wp_insert_post($new_post); inserting the post

    $category_ids is self-explanatory, the IDs of your custom cats pulled form the line above

    and product_category is my custom taxonomy, could just be category if you are using normal categories

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to add Taxonomy to a post’ is closed to new replies.