after_setup_theme
fires before init
, so in this case the code is trying to insert a term into your taxonomy before WordPress is aware that your taxonomy exists!
Generally, I feel like init
is a better location for both pieces of functionality unless you have a reason to do otherwise. But however you resolve it, if you keep the two in separate functions and use the same action, you might want to give the hook which is used to insert terms a larger priority number just for peace of mind, such that it will most definitively always execute after the taxonomy is registered.
Related Posts:
- Using wp_query is it possible to orderby taxonomy?
- How to use taxonomies on attachments with the new Media Library?
- How to add images to taxonomies?
- Can you add the visual editor to the description field for custom taxonomies?
- Check if a post has any term in this custom taxonomy?
- custom post type taxonomy “tag” archive : no post found
- Add custom taxonomy fields when creating a new taxonomy
- Contact Form 7 – Populate Select List With Taxonomy [closed]
- How to display custom taxonomies in posts?
- Get taxonomy names by post id
- Creating Custom Taxonomy without mapping to any post type
- Why is my working Custom Taxonomy not in get_taxonomies array?
- Custom taxonomy hide meta box but show in menu
- display posts with same taxonomy term
- Exclude specific slug in ‘get_terms’
- wp_insert_term – parent & child problem
- Is there a way to disable a term rather than deleting it?
- Widget to display custom taxonomy tag cloud
- Modify Term Update Redirection
- Hook to process a new taxonomy tag before it is created?
- Return only the custom sub-term for custom post type, do not echo term-parent
- Get total number of comments from posts in a specific custom taxonomy
- Custom taxonomy on permalink
- Check if current term is a child of another term
- Custom hierarchal taxonomy loses interface hierarchy when selecting parent & children
- get_terms() doesn’t return empty terms even though hide_empty is false
- How do I filter posts by taxomony using AJAX
- SQL QUERY needed to get POST category (taxonomy) ? – MUST be SQL statement
- Remove Category description textarea
- Formating the_terms() function output
- Archive template for taxonomy terms
- Multiple users – only allow them to manage their own terms for custom taxonomy when logged in
- Custom taxonomy on users with UI
- How to return a list of custom taxonomy terms via the Gutenberg getEntityRecords method
- Create taxonomy with meta term using the WP Rest Api
- wp_options table value
- Custom Taxonomy Only Showing Top Level Terms in Admin?
- How can I set up a category “overview” page?
- Post tags saving as both tag name & tag ID on post update when tags are displayed as checkboxes
- Sort posts by number of matched terms
- Get current term’s ID
- Is it possible to get a Previous/Next Taxonomy term archive URL?
- Looping Through Custom Tax Terms and Displaying All Posts For Each
- Taxonomy Relationships
- Possible to register multiple custom taxonomies in one function?
- How to get the top most term (top ancestor) of a custom taxonomy child term?
- Taxonomies not appearing in columns on dashboard
- Combine multiple custom user taxonomy in single url
- How to modify default taxonomy field to a single text field?
- Add custom taxonomy to default category taxonomy?
- How to set hierarchical terms to a post using wp_set_object_terms
- Echo taxonomy term meta on author.php
- Hierarchical display of custom taxonomy
- How do I display a tag cloud with both post tags AND a custom taxonomy?
- Adding session variable and/or cookie based on user-selected input
- How to output the taxonomy term name in a widget
- How to link categories to custom taxonomy terms?
- List taxonomy / category count showing list published posts only
- How to display term description in empty terms archive?
- Alternative for is_taxonomy() to workaround theme’s default sidebar
- What is the current page’s Taxonomy?
- Loop custom post type by taxonomy (Category)
- Any way to make custom taxonomy field searchable?
- Get custom taxonomy term url on archive page
- Custom Taxonomy Template Variables Available?
- query posts returns 10 records
- get_terms() – unexpected ‘=>’ (T_DOUBLE_ARROW) error
- Display woocommerce product_cat child terms with thumbnails
- get_term_children specific no id
- query grandchildren taxonomy terms
- Custom Search only for my Custom Taxonomy Page – data
- Insert taxonomy term to different table
- Getting taxonomies specific to categories
- Remove Tag Cloud Words from Custom Taxonomy
- How to add/enqueue Custom CSS for a custom taxonomy page?
- wp_get_object_terms count on taxonomies within an category archive
- Group custom taxonomies based on tags contained in their posts
- Make custom post type display with custom taxonomy in url
- Prevent random entries in hierarchical false taxonomies
- Exporting CSV of users with custom user taxonomies out of WordPress
- How do I create a term for every value of a post meta?
- Taxonomies starting with a hyphen (minus) to assign B.C. dates to a post
- is_tax not working for custom taxonomy
- Querying posts globally based on custom taxonomy with its own taxonomymeta table
- Add custom display condition to Elementor Theme Builder for custom taxonomy children, grandchildren, and great-grandchildren
- Save selected terms in order of custom taxonomy in post
- How to delete unused terms?
- Add text in custom taxonomy
- How do I check if a post has a term with a particular ancestor/parent?
- Child terms with improper parent in the url should redirect to 404
- Taxonomy entries are spawning copies of existing entries with the new title as the existing ID, since upgrade
- How to get parent and child name in taxonomy page
- How to enforce a requirement for custom taxonomy
- Issue with WordPress Automatically Assigning Terms to Multiple Posts
- Change taxonomy key of existing and future taxonomy posts
- Cannot set custom taxonomies when creating post
- How to call parent and child category name in separate div?
- Taxonomy archives based on Custom Post Types
- Creating a page that will dynamically get posts from 2 taxonomies
- Hiearchical terms structure and performance