As far as I got you right, the following code is all you need to solve this.
function my_function( $post_id ){
if ( ! wp_is_post_revision( $post_id ) ){
$post = get_post( $post_id );
$my_args = array(
'ID' => $post_id,
'post_name' => ''
);
// unhook this function so it doesn't loop infinitely
remove_action( 'save_post', 'my_function' );
// update the post, which calls save_post again
wp_update_post( $my_args );
// re-hook this function
add_action( 'save_post', 'my_function' );
}
}
add_action( 'save_post', 'my_function' );
See wp_update_post in the codex.
I just tested the code in WordPress 5.1 with the block editor.
Related Posts:
- What is wp_insert_term “alias_of” arg for?
- Can we have same term slug in different taxonomies?
- taxonomy/category term in URL slug irrelevant for post?
- How to show a hierarchical terms list?
- Need a simple but complete example of adding metabox to taxonomy
- tax_query in get_posts() not working?
- Automatically Assign Parent Terms When A Child Term is Selected
- get term by id without taxonomy
- get a specific taxonomy term name
- Exclude specific slug in ‘get_terms’
- wp_set_object_terms() Fails to Set Terms
- List Hierarchical Term List with Count with Related Term
- Is there a way to set singular/plural labels for taxonomy term names?
- get_terms() How many is TOO many?
- get_terms with posts that have a different taxonomy with term x
- List all taxonomy terms / Show links if posts are attached, else names
- How to add terms to taxonomy with wp_insert_terms?
- Get_term_by only returns one item from array
- Is there any difference between post in child term and child & parent terms?
- Set default (auto) slug prefix for Tags
- Create and move terms for taxonomies
- Missing term_id and term_taxonomy_id when adding a term using wp_insert_term() function
- How to get the last term from taxonomy?
- Add custom taxonomy terms to WordPress menu dynamically & append #slug to url
- Count posts for each taxonomy term for each month
- List post from current taxonomy children
- What hooks/filters are there to alter selected terms on post save?
- Count argument in get_terms has no effect on ouput/doesn’t work
- How can I remove links from the function “get term list”?
- Get Term names from WP Term Object
- tax_query: What to pass when I want to have all terms?
- Add a term to an attachment submitted from front end
- orphaned taxonomy terms remove by sql query
- functions to create term and child terms
- has_term not working
- Filter taxonomy terms using multiple id in the edit-tags.php
- How to use a Term Meta Field as a link
- what tables uses wp_get_post_terms
- Custom Taxonomy leads to 404 page
- WordPress built-in method to extract array of term IDs?
- How do I get the current tag out of a taxonomy?
- Variable in Array Not Working
- Add current class to queried term on taxonomy term archive
- How to list 2 taxonomy terms for a post, based on their hierarchy
- Should I be using custom post types for this or terms and taxonomies?
- get_terms problem : related articles
- Set post terms on post publish
- Why “Warning: Invalid argument supplied for foreach()”
- Order wordpress taxonomy parent terms by their children count
- WordPress User Taxonomy Saved Values
- how to get the assigned child term of the term’s parent
- get_the_terms error
- How can I find the taxonomy in edited_{taxonomy}?
- Display Taxonomy Terms in an option tag with value being the slug
- Use get_terms to get post_tags but limit to a taxonomy
- Changing taxonomy term by slug (wp_update_term)
- Set attachment tags from attachment’s custom field data
- Set multiple Post Terms in same Taxonomy
- How can I increase the length for the taxonomy term slug?
- how to show only last child terms of a taxonomy
- How to get the top level parent term Advanced Custom Field values in the child terms
- Allow a Taxonomy Term to be Used Only Once Across All Posts
- Count Published & Draft Posts Associated With Each Term
- Ordering Taxonomies / Changing term_id
- Show child terms of current term of the taxonomy
- Fetch and ACF image field from a custom taxonomy outside category/archive page? [closed]
- conditional statement based on terms
- Adding taxonomy terms based on custom field
- Multi Taxonomies same terms
- Make taxonomy terms appear in the order they were made
- get_the_term_list – Return links to edit.php instead of link to taxonomy archive template
- How to sync to custom taxonomies (tag structure)
- Exclude posts with taxonomy term from appearing on home page query
- Comma separated tax terms, with “and” before last item [duplicate]
- the_terms characters not limiting
- List taxonomy term slugs within shortcode (do_shortcode)
- `get_terms()` with `child_of` and `childless` combined
- Hierarchical list of custom taxonomy terms
- Add text to the end of each list item in wp_list_categories
- Return Taxonomy Name for Each Term
- echo term name outside the loop, using term slug
- Get term from multiple taxonomy
- Modify output of wp_dropdown_categories to add term IDs to each option
- How to return newly added terms when using wp_set_object_terms
- Blogroll links sorted by category in a table
- How to get terms from a custom taxonomies after WordPress 4.5.0
- How to update a taxonomy term for a custom post type with auto incrementing number
- How to relate a user object to taxonomy term?
- How to display taxonomy term custom meta (using wp_get_object_terms?)?
- SQL query joining on taxonomy tables not returning what I would expect
- Filtering elements by taxonomy slug
- Echo taxonomy name – second level
- Match and Merge Terms in Different Taxonomies
- If has_term, load other theme
- Get terms in hierarchical taxonomy
- How can I query all post with currrent taxonomy term?
- Taxonomy Checkbox Admin Panel
- Retrieve all term IDs of post
- Related terms – Terms that feature in post of current term
- Bug using wp_insert_term with switch_to_blog