WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Function to insert post into a category.

[Resolved] Function to insert post into a category.

  • 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)
  • 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 (http://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 ‘[Resolved] Function to insert post into a category.’ is closed to new replies.
Skip to toolbar