function func_update_post_name( $post_id, $post ){ if ( 'post-type-slug' == $post->post_type ) { remove_action( 'save_post', 'func_update_post_name',30,2 ); // update the post slug wp_update_post( array( 'ID' => $post_id, 'post_name' => uniqid() )); add_action( 'save_post', 'func_update_post_name', 30, 2 ); } } add_action( 'save_post', 'func_update_post_name', 30, 2 );
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter