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 custom content template part for a custom post type on main query using a plugin
- How to get term link that crosses different custom post types?
- Removing Edit Permalink/View “Custom Post Type” areas
- Unable to save custom taxonomy terms in a custom-built metabox
- Determine which template-{slug}.php is being loaded
- How to sort CPT by custom meta value (date), and return posts month by month
- Remove POST_TYPE from custom post type permalink
- How to rename image at uploading on specific plugin or post-type in WordPress
- How can I display my custom metaboxes on a custom post template?
- Adding dropdown select meta box to custom post type – seems restAPI is interfering
- Custom posts don’t work
- Get term name and term parent into custom post type permalink
- Is it possible to create relational metabox values in a custom post?
- Changing custom type name hides the posts
- Custom post type archive page blank
- Custom post listing page layout of custom post type
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- Show Custom Post Type meta boxes only on Page Edit
- WordPress custom post type capabilities issue
- i cant see the max_num_pages of a custom wp query
- Archieve.php not loading for custom post type
- HowTo: Custom Post Type (Meta) to Custom Table
- Specify a particular page to list all custom types
- Where is the sticky post option?
- How to group navigation items in the admin panel
- WP_Query with custom post type ID
- Unable to display selected post title in frontend from metabox wp_dropdown_pages()
- How to access the thank you page from the single post?
- Topic won’t save for a custom post type — how to debug?
- How can I output WPAlchemy repeating fields meta values in my page template?
- Questions regarding add_meta_box()
- Change Dropdown jQuery to show/hide but with default place holder that shows all
- Post type to appear on every page on site
- set a custom post type to a taxonomy term programmatically in metabox
- wp_dropdown_pages doesn’t allow me to select more than one custom post type
- Execute code only after user clicks ‘update’ button for CPT being edited
- Delete custom post type metadata without deleting the post in admin area
- Can the wp_posts table have the same slug (post_name) in multiple statuses (post_status)?
- Metabox is not saving
- Loop carousel slider in wordpress
- get_pages can’t load pages with custom post types
- Add category slug as class attribute in a link array
- Custom post types working in functions.php but not in plugin
- Display div based on Group metabox selection [closed]
- Meta box not displaying on the plugin page