• Resolved fatalx

    (@fatalx)


    Hello,

    I was wondering if there is a function that will add a post (via post id) into specific categories (custom taxonomies in my case). I have been looking around for the function that does it but could not find it.

    Thanks

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

    (@fatalx)

    I figured out my problem. I found this function

    wp_set_object_terms

    it’s used this way

    wp_set_object_terms($postid,$cat_ids,$taxonomy);

    $cat_ids has to be an array even if it’s only one element, and you have to make sure that all the ids are integers.

    Hope this helps someone else.

    Very helpful for me!

    I am working on my website (https://post.qp-x.com/) and I didn’t know how to insert a category, but now everything works fine.

    Thank you, fatalx!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Function to insert post into a category.’ is closed to new replies.