See Codex page for is_taxonomy
This function is deprecated as of Version 3.0. Please use taxonomy_exists instead.
wp_insert_term
uses taxonomy_exists
to check if the taxonomy exists. This means if the taxonomy is a registered taxonomy. (It would be odd if wp_insert_term
only you allowed to add a term to taxonomies with existing terms 🙂 )
To catch an error you can use is_wp_error
. E.g.
$result = wp_insert_term(...);
if ( is_wp_error( $result ) ) {
$error_string = $result->get_error_message();
echo '<div id="message" class="error"><p>' . $error_string . '</p> </div>';
}else{
list($term_id,$taxonomy_id) = $result;
}
Related Posts:
- How to show the category filter that’s shown on the ‘All post’ pages on a custom post type page in the admin area?
- What are these undocumented arguments for register_taxonomy?
- How to get my register taxonomy
- How to disable the use of certain words in categories
- How to show a hierarchical terms list?
- Why does get_term() require taxonomy? Are term_ids not unique?
- Automatically Assign Parent Terms When A Child Term is Selected
- get term by id without taxonomy
- Taxonomy terms sort by… Last name!
- WordPress – Creating multiple versions of the same single-customtype.php depending on selected taxonomy categories
- Exclude custom taxonomy from search results and archive pages
- get_terms with posts that have a different taxonomy with term x
- check if tag exists in wp database
- How to update taxonomy custom field with wp_update_term()?
- Add Thumbnail to wp_list_categories()
- Display Post by taxonomy and taxonomy child
- Fatal error: Call to undefined method stdClass::filter() in wp-includes\taxonomy.php on line 805
- WP native tag suggest metabox. How does it process tag id?
- Change order of WordPress tag cloud
- Let users create a new custom taxonomy entry from frontend (without creating a post)
- taxonomy/category term in URL slug irrelevant for post?
- How to use a Term Meta Field as a link
- Embed YouTube video on category description
- Custom Taxonomy leads to 404 page
- WordPress built-in method to extract array of term IDs?
- Show only, when taxonomy has posts?
- Convert Custom Post Types to Custom Taxonomies
- How to Retrieve a Taxonomy Term’s ID?
- Why “Warning: Invalid argument supplied for foreach()”
- WordPress User Taxonomy Saved Values
- Display Taxonomy Description on edit-tags screen?
- get_the_terms error
- Order custom Taxomony alphabetically and reversal after clicking a button?
- extend HierarchicalTermSelector function with custom renderTerms
- Searching in wordpress using wp_term_taxonomy table
- Pulling Data from CSV vs. pulling data from database
- Attaching taxonomy data to taxonomy with wp_insert_post
- Problem with orderby
- Problem with Query on Taxonomy
- Taxonomy archive + query attachments = duplicate results
- Exclude posts which have any term in a certain taxonomy from the query
- Comma separated tax terms, with “and” before last item [duplicate]
- How to add and display a taxonomy term image in any template? (Taxonomy Images)
- Hierarchical list of custom taxonomy terms
- Get Link to Feed On Term or Taxonomy
- Categorize wordpress tags
- Creating links to a page displaying posts from a particular category
- HTML in category name
- How can I completely hide a taxonomy term from “frontend”? [closed]
- Blogroll links sorted by category in a table
- How to display taxonomy term custom meta (using wp_get_object_terms?)?
- How to get if child category of this category is empty?
- Adding inline help to category/taxonomy checkboxes in admin sidebar
- Taxonomy vs Post Status
- Automatically show ‘taxonomy’ meta box by default in Appearance > Menus?
- Retrieve all term IDs of post
- Prevent certain subscribers from seeing specific taxonomies (changes frequently)
- child_of not working in wp_dropdown_categories
- How to display posts from two taxonomies?
- Using taxonomies to handle layout?
- How to embed the Taxonomy Admin screen in to a Tab of a Settings Page in a plugin
- update_term_meta not working
- Getting more info about the taxonomy?
- Calling an Archive Page with specific Tag/Tax ID
- Assign Multiple Values from Post Fields to Taxonomy Terms
- how can send a parameter by click on gender-link to filter a post by gender and product taxo
- How to make HTML select options searchable
- Why doesn’t ‘post__not_in’ work with ‘cat’?
- How best to add Author or Artist to product
- Order custom taxonomy hierarchy
- Including taxonomy in searches
- Different Sidebar for same Taxonomy
- How Do I Register Two Taxonomies with one Parent of the Other?
- I want to change the slugs of my terms dynamically
- Translation ready code format for taxonomy
- taxonomy_edit_form_fields output after term fields
- Make/create a category for every page
- All tag/category/custom taxonomy archives 404
- Get a specific category in multiple categories
- Create multidimensional array of taxonomies
- $product->ID in has_term() not working, but manually inputting the ID works, why?
- how do you get one specific term from a shortcode attribute?
- How to customize taxonomy edit page
- Fatal error Call to a member function filter()
- Templates files for custom post type with custom tags
- Using is_tax with multiple taxonomies
- Taxonomy pages, stop them indexing or being generated?
- Categorizing posts by location
- How to filter the terms to a special custom taxonomy?
- Pages throwing 404 error on server load
- Display yesterday’s last post’s Custom field from Unique terms of one Taxonomies
- Apply custom taxonomy archive template to children
- Why does my taxonomy code display the first alphabetical term?
- Custom Taxonomy link out the loop
- Why can’t I exclude a term ID from either get_terms or WP_Term_query?
- IF taxonomy archive is hierarchical THEN
- What is the ‘selected’ parameter in wp_dropdown_categories() for?
- Taxonomy works in local XAMPP but doesn’t work live
- Hiding a tag from display
- taxonomy change to post/page type