Inserting two categories
Just pass array with category terms in wp_set_post_terms taxonomy parameter. global $post; $post_id = $post->ID;//get the current post id $terms = array(‘term1′,’term2’); $taxonomy = ‘category’; $append = false; // or true wp_set_post_terms( $post_id, $terms, $taxonomy, $append );