You need to insert your term after the init hook (i.e. when the taxonomy is registered):
function create_tax()
{
$args = array(...);
register_taxonomy('custom_tax', array('post'), $args);
// Now we're safe
$result = wp_insert_term('Test Term', 'custom_tax', array('parent'=>0) );
}
Related Posts:
- Difference Between Filter and Action Hooks?
- Which hook should be used to add an action containing a redirect?
- How do you use the plugin boilerplate loader class to hook actions and filters?
- How Do I Load My Action Earlier Enough?
- Does WP fire delete_post when trashed posts are automatically deleted?
- What’s the earliest point I can get the queried object ID?
- How do I Make a Theme “plugin-ready”?
- What’s the difference between hooks, filters and actions? [duplicate]
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- Is it possible to create an action hook using do_action() within add_action()?
- How can I hook into existing WordPress Bulk actions?
- Define a function outside a class and call the function using action or filter hook
- Create a plugin to change the action to which a function is hooked
- Modifying values with add_action to be sent to db
- Woocommerce – Hide a Column in Cart Table
- Hook to get image filename when it is uploaded
- Which are the hooks run before/after when a category’s deletion?
- Should action callbacks start with a verb?
- Execute Hook on the footer or header after activating a plugin
- Namespaced action and filter tags
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- $_FILES empty on created_{taxonomy} and create_{taxonomy} yet is is not on edit_{taxonomy}
- Why is the WordPress taxonomy not registering?
- Translate slug in WPMU with PO files
- I have 2 plugins using the same wp_login action hook and one is not working
- How dynamic action login_form_{action} is working
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- How to get all queries’s results after they have executed?
- Bug: Post needs to be updated twice when adding action for save_post hook
- When does save_post hook fire on post save/update
- Hook add_attachment error
- Call to undefined function is_home() or any conditional tags
- Non editable custom taxonomy
- How to create taxonomy without using register_taxonomy () function
- How to find list of all functions bind to a particular hook from my plugin?
- Add location tag to wordpress posts
- Can I Hook Into the TinyMCE Insert/Edit Link Button to Use Shortlink For Post?
- Action / Hook when a new plugin is added
- apply_filters() and call_user_func() to define and call a function outside a class
- WordPress Plugin Boilerplate – add actions and/or filters based on user’s role
- remove different admin menu for specific users
- set a custom post type to a taxonomy term programmatically in metabox
- add_option_{$option} action hook not being called
- Does WordPress have something like timer hook?
- add_action priority and taxonomy used in plugin
- How can I set a dynamic value for post_updated_messages based on return value of post_updated?
- How to display custom taxonomy and terms using/creating plugin template
- Insert plugin html content to a specific spot in the frontpage
- Apply function on all action hooks?
- Ninja Forms: Front-End Forms, Post ID?
- Send push when new post is published in a certain category
- Unable to change footer using wp_footer action hook
- wp_set_object_terms not updating database without a die()
- Get Time Taken By Each Action Hook in WordPress
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- Adding widgets to my plugin page instead of WordPress dashboard
- How to set taxonomy in custom plugin?
- How to limit number of number of categories displayed by categories widget
- Adding function to Genesis genesis_header [closed]
- How to filter content for specific content variable
- template_redirect or admin-ajax.php?
- WordPress custom taxonomy check box to dropdown
- load_plugin_textdomain doestn’t work with add_action plugins_loaded
- How to Get Current Custom Post Type Associated Taxonomy Term
- Force HTTPS 301 redirect with hook
- Show error message after exception handled
- How to remove plugin-specific custom taxonomy terms when plugin is uninstalled?
- Add a new confirmation page before saving
- Valid filenames for add_action’s first parameter
- WordPress class, using add_action to call member function does not work
- Where do I put my add_action(… and add_filter(… and do I need to remove them?
- use of do_action() without any functions attached
- What happens when two or more plugins use the same hook?
- Does admin_print_scripts-$hook_suffix work for nested paths to individual files?
- Plugin uninstall function is not working
- Delete data from database using row action
- flush rewrite rules after plugin update?
- Plugin does not add action
- Remove an action by extending class and replacing it
- Add child pages to submenu automatically
- After plugin activation hook
- term_exists() returning NULL on term that exists
- Taxonomies within plugin invalid
- How to replace default comments with custom HTML?
- Odd map_meta_cap $args on post edit — sometimes integer, sometimes string
- Trying to get class to instantiate ONCE (or, “why do I keep punching myself in the head?”)
- How can I create a custom plugin that allows anonymous users to signup without registering?
- hook filter after the_content on a specific page
- Bind a function with its own argument to show something dynamically after every content
- A question about add_action()
- Is there an admin hook that will let me read GET variable before it’s too late to set the header Location
- What is the action hook that deletes a taxonomy term from the backend? And how to retireve the term id before deleting it?
- Let plugin check if taxonomy is already registered by another plugin
- Why enqueue styles on hook?
- What’s the hook for filtering every texts of site?
- Hook for page Request?
- Associate multiple email addresses with the same user account, so they can log in with either
- WooCommerce change Tax Class programmatically when Recalculating an existing Order [closed]
- Run command “composer install” when activating wordpress plugin
- Update variable value via add_filter