wp_set_post_terms()
requires you to provide term id not the term name or slug when it is a hierarchical taxonomy.
From the codex:
For hierarchical terms (such as categories), you must always pass the
id rather than the term name to avoid confusion where there may be
another child with the same name.
Try the code below:
$term_id = term_exists( 'bus', 'category_type_bus' );
wp_set_post_terms( '2653', array( $term_id ), 'category_type_bus' );
The function get_term_by()
also can be used instead of term_exists()
Hope it helps.
Related Posts:
- Custom columns on edit-tags.php main page
- Is there a way to ‘Lock’ a Taxonomy?
- Return only the custom sub-term for custom post type, do not echo term-parent
- wp_insert_term is adding a term that has no name
- Get total number of comments from posts in a specific custom taxonomy
- Display one post from each term in a custom taxonomy [closed]
- Is it possible to add taxonomies to user profiles?
- Get terms from multiple taxonomies
- Connect Users and Taxonomies
- WordPress json api taxonomy index method
- get_terms showing link to category even if all posts are drafts
- How to restrict on selecting child taxonomy
- Sort Custom Taxonomy Terms in admin by custom order
- Is it possible to sort the post based on a custom field?
- How do I get terms as a list for a specific post?
- Change in custom taxonomy permalink causes 404 error for another custom taxonomy
- Checking if a Page has an Associated Term?
- Displaying ACF image field [closed]
- How get custom field from custom taxonomy?
- What are terms and taxonomy, how they related to post and how these three are stored in database?
- Get multiple term objects by ids
- Echo custom taxonomy term name
- Taxonomy.php issue with search and filters
- Move terms from one taxonomy to another keeping the hierarchy
- How can I get WP to build a feed based on multiple taxonomy terms
- Getting the selected terms for custom taxonomies in the editor
- Set custom post type terms by id without knowing taxonomy
- Catchable fatal error on custom category post
- How to add contents of a custom field to a taxonomy term list?
- How to target parent product category and its children using WooCommerce?
- wordpress testimonials
- Custom Taxonomies not retaining hierarchy while importing from one site to another
- Remove custom taxonomy column from my custom post type columns
- Output single post custom taxonomy child terms
- Check if custom taxonomy has posts with get_categories()
- How to get custom category’s link?
- Edit custom taxonomy description programatically
- why are the term_id and term_taxonomy_id doesn’t match on custom taxonomies, but are duplicates on categories
- saving meta/custom field to tag
- Get taxonomy name for the current post
- How to get posts that contain multiple terms from multiple taxonomies?
- Cannot delete or edit a single term in a custom taxonomy, taxonomy name is wrong?
- View the complete list of a taxonomy in the navigation menu
- Duplicate slug/permalink issue
- Getting taxonomies associated with a specified post type
- Changing input type from text to multi select dropdown – skill taxonomy
- Get name of taxonomies of current page
- How to list the taxonomy terms that fit the custom query?
- What’s the best way to add taxonomy’s image in 2017?
- Count of posts by different parameters?
- Geographic search with taxonomy structure [duplicate]
- Add custom taxonomy as a css class
- Wp_query…a type of term a different div
- Taxonomy page shows category in title
- SQL / wp_update_post: change post custom field to CPT post taxonomy
- Proper way to create taxonomy queries
- search using multiple taxonomies and keyword
- Need equivalent of single_term_slug
- Custom Permalink Structure for terms/taxonomies of custom post type
- register_taxonomy for both ‘Post’ & ‘Page’
- List one post only from each subcategory using get_posts?
- Multiple Drop-Down custom taxonomies search
- Issue adding custom taxonomies to custom post type (PHP)
- Taxonomy URL rewrite whilst keeping filtered posts?
- Search custom taxonomy via query-string?
- problem : Custom taxonomy template not showing
- How to loop custom posts that have an exact match in taxonomy terms?
- True or F False Setting of ‘with_front’ Parameter of Rewrite Is returning Exact Same result
- WordPress not saving tags for custom taxonomy term description
- How to Implement Custom Taxonomy Conditional Page?
- wp_insert_post not adding taxonomy (using wp_set_object_terms)
- Filter “get_terms” query
- Display multiple taxonomies in a function
- Remove Custom metabox from particular page template is used
- generate random slug when adding taxonomy
- Add and Custom category for posts “PAGE”
- Exporting Custom Taxonomy Description without Plugin
- How do I display post count of a custom post type with custom category taxonomy in wp_menu_nav?
- WordPress Main Menu with dynamic url
- wp_insert_post and custom taxonomy
- Custom Taxonomy – Dropdown
- Error 404 in Custom taxonomy with pagination
- Custom post type term names with ampersand in the term name
- WordPress Taxonomy Permalinks – Custom?
- Need help understanding a rewrite with multi-level taxonomy
- How to query authors by custom taxonomy?
- Display custom post term or taxonomy
- Attaching meta box to specific category/taxonomy in custom post type
- Change Permalink to Value of Custom Field
- Display custom post taxonomies
- Gravity prerender taxonomy [closed]
- Custom Taxonomy type in nav menu
- Advanced search: roles and multiple taxonomies
- One taxonomy template for all categories?
- Custom Fields link to other pages, not search
- Removing fields from category/taxonomy edit form
- Remove ‘portfolio’ from URL
- Add Gutenberg editor to edit taxonomy (category) page
- post_type_link not working for posts without terms
- Why my archive title isn’t showing?