You have to use a wp_update_post
function and update the required fields based on available fields in WP_Post
class.
add_action( 'save_post', 'wpse75679_save_post' );
function wpse75679_save_post( $post_id )
{
if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
// verify post is not a revision
if ( ! wp_is_post_revision( $post_id ) ) {
// unhook this function to prevent infinite loop
remove_action( 'save_post', 'wpse75679_save_post' );
// update the post slug and title
wp_update_post( array(
'ID' => $post_id,
'post_title' => 'new-title'
'post_name' => 'new-slug'
));
// re-hook this function
add_action( 'save_post', 'wpse75679_save_post' );
}
Related Posts:
- Not Able to Display Metabox Saved Checkbox and Selected option After Save/ Update
- Where to put my code: plugin or functions.php?
- Mini-Site Strategy
- How to set a fall back template for a custom post type in a plugin?
- How to add multiple images to a custom post type single post?
- How to add multiple images to custom post type?
- Where to put archive-{post-type}.php
- WordPress metabox file upload in custom post [duplicate]
- Save or update data when custom post published
- How to: add option to add more checkboxes on custom post type
- How to add multiple featured image in meta box in post editor?
- how to set default value for checkbox in wordpress
- Adding Meta Boxes while Registering a Post Type in a Class
- need advice on how to do a lists using custom post types – taxonomy vs postmeta
- How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)
- What’s the difference between same wp functions get_posts(); functions in different form?
- How to Upload CSV Data into Custom Post Type Data with Metabox programmatically
- How to use TinyMCE Editor for one of my custom post meta field?
- Adding a metabox on a CPT’s submenu page
- custom comments form for custom post type
- Wrap meta boxes & data handling for specific post types in classes?
- Save Multiple Metabox values
- detect your custom post type in WordPress
- How to insert data into meta box from another plugin?
- Custom Meta Box returns no HTML
- Creating alternate meta box context locations
- Is it possible to sort metabox teaxtarea values?
- Create a select metabox that the user can pupolate?
- Having Issue on Getting Metabox Checkbox Value
- Custom meta box in custom post type not working
- Not Able to Add New Class To CPT Attachment Image
- Wp Meta Query does not work while simple Query Works
- Custom post category name showing empty
- How to store the third party script with HTML code in the wordpress custom input field?
- Get next and prev item from custom WP_Query and Custom Post Type
- Error 404 change permalink term custom term taxonomy
- Show a custom post title in another custom post type in Meta box
- I have a random letter appearing before my content. Where to start looking for the cause?
- WP_List_Table Inside Metabox Not Working on Clicking Search Button
- Problem with multi checkboxes value in metabox?
- Getting data from dynamically allocated metaboxes within a custom post
- Admin metabox with custom post type dropdown option not update choosed input after saving
- Having issue on Loading Meta Data From CSV to CPT
- Front End users account with lots of user Roles (not Woocommerce)
- How save custom meta type posts multicheck grouped by taxonomy (with CMB2) [closed]
- Custom post type that lets users create a set of posts?
- php output of generated custom metabox
- call a function when insert and update a custom post type
- Custom meta box in editor of custom post type not working
- Not Able to Get Custom Post Type in Single and Single-custom-post-type
- How to develop custom URL redirection
- Search form to find custom meta box generated data
- Issue on Counting CPT’s Under Taxonomy Term
- Need some hints for my own WP theme development
- How to consume external API from WordPress post editor and display the response data in the custom field?
- How to add extra input fields to CPT’s comment form?
- Get all of user’s custom post types in WP Admin for plugin
- Custom Post Type with metaboxes (no content) only?
- Issue with pre_get_posts on custom post type archive pages
- Custom Post Type Navigation on Custom Field
- Why do I lose the content of meta boxes when I leave the page?
- Dynamically add / duplicate custom meta in custom post types
- Add TinyMCE to CPT metaboxes in 3.1?
- Custom Post Type Metabox – Not Saving
- How can I show/add/save custom metaboxes as an Array of values?
- Plugin translation not working apart from name and description
- Get rewrite slug of custom post type in template
- WordPress nl2br is not converting newline to html line break when saving metabox value
- Unable to show meta box data in frontend
- ACF simple text field value not showing
- WordPress custom meta field for custom post not storing data
- A good strategy to print custom posts (offer) that are checked inside the metabox of a post?
- Custom Post Type rewrite
- Admin notice not displaying
- How can I create a custom meta box to add an mp4 video to a page?
- Made Custom Post Types, but single.php not working
- How to Duplicate (multiple meta box)?
- Is it possible to place custom post type files inside a folder in theme directory?
- Custom Post Type: Upload Multiple Images
- window.send_to_editor and jQuery .attr() conflicts with multiple custom upload image meta boxes
- advanced search forms with 3 input text and that the main problem 3 input text
- Displaying a custom post types custom taxonomy value?
- List custom post types in metabox
- Detect where custom post type is declared
- Metadata for a taxonomy – is there any WordPress way of doing this?
- Create custom PAGE with register_post_type
- List of Posts in a Custom Field
- Save an array from drop-down in custom meta box
- Should I use custom menu, C.P.T. or theme options, or something else for this?
- Using My-Meta-Box-Class plugin, how is ‘Date’ value stored?
- Pull a post based on a meta value in a custom post type
- Populate Custom Fields in a Custom Post Type?
- Change meta box when the page’s template is changed
- Duplicate Custom Header Functionality into the post edit screen
- Send email button in custom post type backend
- Hook to override title, image and content
- Insert Multiple Post with Same Publish Button
- Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?
- Cannot save Checkbox meta box value from a Custom Post Type
- Adding dropdown select meta box to custom post type – seems restAPI is interfering