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 );
Related Posts:
- Get custom post type by category in a page template
- Query posts by custom post type and custom taxonomy
- How to get only one category of custom post type?
- Weird problem happening with custom taxonmy when creating/updating posts
- Conditional Query of Custom Post Type and custom taxonomy
- Control content before and after custom post type loop
- attach CPT data to a taxonomy
- Creating a non-hierarchical Taxonomy that behaves like categories
- Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
- Query Multiple Custom Post Types & Exclude a Taxonomy Term
- How do I ensure that post_type and Taxonomy use the same slug?
- WordPress query posts by custom post type not workng
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- How do I query a custom post type with a custom taxonomy?
- what is the correct way to compare dates in a WP query_posts meta_query
- How do I append multiple taxonomies to the URL?
- Display a query with multiple post types and same relationship on a single page
- WordPress Custom Post Types with a page as a parent?
- Get Custom Taxonomy ID within loop
- Custom post status not working
- Custom Taxonomy with Custom Post Type Finds No Posts
- Associating an “author” with a custom taxonomy
- TV Show database – Best way for structuring it?
- Correct way to use a form to to filter custom posts by taxonomy terms?
- how to group custom post type posts by custom taxonomy terms
- Showing current taxonomy terms
- Categories under custom post types doesn’t show properly
- Posts per Page on custom Taxonomy Template
- How to get the parent’s taxonomy?
- Ajax filter with custom taxonomies
- automatically create taxonomy with same name as post title
- Filter posts with ajax form and checkboxes
- Custom Taxonomy conditionals
- Query post types with multiple keys
- pre get posts changing the query
- Error after deleting Custom Post Type with a function (no trash used)
- Query for posts in 2 taxonomies
- Get all taxonomies for all post types
- Append taxonomy terms as class names in markup?
- After deleting a post are terms, and custom meta deleted?
- Get all posts WHERE custom_field is LIKE value
- How do you output custom code between posts in the loop?
- Show ACF field from custom taxonomy and display on the single template
- Best practice for adding posts in bulk
- ‘category__and’ for custom taxonomy?
- WP 3.1 getting tax_query to work in query_posts()
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- List terms from Custom Taxonomy
- Programmatically adding posts
- Keep main articles and author blogs seprerate, News / Magazine like site
- How to dynamically build a multiple taxonomy query loop within a post type’s single loop?
- Why is my custom loop not filtering correctly nor paginating?
- Custom post types with custom directories
- WP_Query search posts by custom post type and custom taxonomy
- List custom post type by custom tax term as page title
- removing custom tax & CPT slug, adding taxonomy term in front of custom type
- Order WordPress Custom Taxonomy Pages & Pagination Not Working
- How to customize admin posts based on the user who is logged in
- Show Two custom Post type and their posts on category page
- How to create an advanced filter search?
- How to output wordpress custom tags separated by comma?
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- how can i get posts from custom post type particular taxonomy category
- Setting posts per page in query_posts
- How to insert content from another Custom Post type into Post?
- Get rewrite slug of custom post type in template
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- How to display selected taxonomies by their parent
- Custom Field Order by Last Name and First Name
- How to query custom post types posts filtered by multiple custom taxonomies through a form selection
- get_posts of Custom Post Type AND Custom Taxonomy
- Query/list all terms and their custom post count
- Received nothing after executing AJAX post function
- How to customize a permalink (URL) structure?
- Archive for custom taxonomy lists all posts instead of current taxonomy
- Display only one post each WEEK
- Get custom post type list for every category shortcode
- How to use custom taxonomies to reference complex relationships?
- Query Custom posts of same taxonomy as the post itself
- A question on creating filters for custom posts using taxonomy
- will post_id ever change? Can I safely use post_id for custom queries?
- List custom taxonomy specific to one custom post type
- Show a Category X’s custom post type on Category X archive page?
- Custom Post Type Query for Sidebar Doesn’t Work on Front Page
- How do I move/order posts with a tag to the end?
- WordPress sort search results by custom order
- 404 error when navigating to a taxonomy page with Cyrillic, what’s wrong?
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- Why are taxonomy terms not saving when using custom meta boxes with radio button taxonomy selectors?
- Hide parent categories when clicked, and show it’s childs
- How to start a new post with custom Taxonomies already set?
- Categorize custom post type
- How to edit this code to get the categories in achieve page?
- Custom post type editor with dynamic selects, one drop down populating a second second drop down not working
- Custom Taxonomy – fields
- CPT: multiple loops with different terms
- Stored meta from attachment, video length?
- tax_query not working?
- Getting Custom Posts with Custom Taxonomy
- Add active class to foundation 6 tabs while looping categories