So, thanks to cjbj I finally found the correct answer! I needed to use edited_term
instead of edit_term
. Very subtle difference. edited_term
fires after a term has been saved.
// insert stuff into description field of taxonomy
function insert_taxonomy_content( $term_id, $tt_id, $taxonomy ){
// only insert content on certain taxonomies
if ( $taxonomy === 'some_custom_taxonomy' ){
// unhook this function so it doesn't loop infinitely
remove_action('edited_term', 'insert_taxonomy_content');
$content = "Some Content";
$update_args = array(
'description' => $content,
);
// update the post, which calls save_post again
wp_update_term( $term_id, $taxonomy, $update_args );
// re-hook this function
add_action('edited_term', 'insert_taxonomy_content');
}
}
add_action('edited_term', 'insert_taxonomy_content', 10, 3);
Related Posts:
- Get Comma Seperated Taxonomy Linked Terms and Last Child Separated By “&” Instead Of Comma
- I am trying to set post terms to a custom taxonomy
- Why is the term of my current page not returning a slug?
- How to prevent multiple custom terms from being created
- delete_term is not working properly with add_action()
- Issues with title-tag and document_title_parts
- Hierarchical taxonomy UI
- Import WordPress XML File from Within Functions.php
- Define custom Page Template without its own .php file
- Does hooking into the same action multiple times drain memory?
- How to influence the information displayed on widget inside wp-admin
- Extract image from content and set it as the featured image
- Is there a hook or function I can use to display all theme files being used on a current page?
- get_term_by not working when in functions.php
- Issue with get_theme_mod returning a blank value instead of the saved value
- Add action hook conditionally – only when home.php in use
- Show modified time if post is actually modified
- why doesnt is_home() work in functions.php
- How to create thumbnails for PDF uploads?
- Implementing DNS Prefetching with WordPress
- Help me to understand wp_header() and wp_footer() functions
- How can I tell if I’m on a login page? [duplicate]
- Formating the_terms() function output
- In WooCommerce I need to modify the thankyou.php page [closed]
- How can I add an extra WooCommerce hook
- Registration Hooks don’t appear to be working
- get_terms not returning any custom taxonomies
- jQuery does not work
- Why does re-using this function not work? [closed]
- Pass parameter to hooked function using custom page template
- Override the WordPress core function wp_referer_field
- How to return hook data when multiple parameters are present?
- Hook into a function without a hook?
- What is the text that appears beside the page titles in the list of pages in the WP admin?
- Remove a category from a post when saving a new post
- How to edit the Tags within the image file URLs?
- Is my code correct to enqueue CSS on a specific page?
- Can’t properly set the_title add_filter to show short_URL
- Control the srcset much more (not all sizes in it each time)
- How to add_filter html template to middle of content
- Filter yoast canonical add_action priority [closed]
- (Woocommerce) Order by price when entering specific category
- How do I hook into the container of wp_nav_menu?
- Remove links from the_content when using filters wp_trim_excerpt
- What is the action hook that deletes a taxonomy term from the backend? And how to retireve the term id before deleting it?
- Is there a way to prevent a function/method from being called outside a specific hook?
- Auto log in hook is requiring a page refresh
- Possible to hook into Media Library preview File column and use a custom image?
- Function not working inside of a function in functions.php
- Hierarchical taxonomy list with modificated term links
- Adding code before post title with the_title produces weird results
- Add back in child theme what the parent theme removed with remove_action
- Writing a function to detect an event
- This code works, but the way I integrated it is breaking the media uploader. How can I integrate it properly?
- WordPress wraps span tags into p tags
- Get term slug by term id and then explode it
- Changing where my author box is printed
- Is it possible to use add_filter in an included file in the child theme’s functions.php?
- Insert Content Before div#main from the functions.php File
- Add Adsense code between job listings – wp job manager plugin
- Get Attachment Category Name
- How add body_class from wp_termmeta
- update_post_meta is Updating with two page id
- How to call a custom taxonomy term name inside a function?
- Replace admin header logo with an image
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- is_home() not working in functions.php file
- How to conditionally add a widget via a hook in functions.php
- How to place a div inside a function that creates a div
- Running a function only once when a taxonomy term is changed
- Changing the text of Upload/Insert on Posts and Pages Screen
- Filter for replacing the WP_query object for a given category
- How to add or delete default value theme options while activate and deactivate theme
- How to get taxonomy tree ids without running expensive loops
- WordPress comment processing . Default unapproved comments detection before posting
- Warning at top of website & top menu gone
- Add custom taxonomy using JS in post editor
- Display a list of random terms from custom taxonomy with shortcode
- Using get_terms for custom taxonomy in functions.php
- Does hook have an effect on increasing the page load?
- Save_post – Warning: Cannot modify header information
- What is the earliest Hook a Script can use?
- Populate acf-field, depending on block name
- How to use WP conditional tag in a functions.php with OCEANWP Theme?
- custom error message for empty username and password using authenticate filter not working
- How Do I Unhook This Parent Theme Function?
- Get post_author email for Zapier Integration
- Calling hooks in functions
- I want to customize the_posts_navigation function by replacing prev and next with images
- wordpress does not see the correct custom taxonomy hierarchy
- How to add custom column into custom post, when field is select
- How can I stop the hook from breaking the login/logout function?
- True email confirmation for registration (keeping unvalidated users from user table)
- Taxonomy On Index Page
- WordPress hooks to call a function inside a construct
- WordPress undefined function error on using add_action() in functions.php
- Custom taxonomy check box now showing up
- Change post count on tag/terms pages to 10
- Only seems to be displaying one child when there are supposed to be multiple
- How to echo the translated custom field?