// alternativ mit 'save_post_{$post_type}'
add_action( 'save_post', 'set_custom_permalink', 10, 3 );
function set_custom_permalink($post_id, $post, $update ) {
if ($post->post_name != '')
return;
// verify post is not a revision
if ( wp_is_post_revision( $post_id ) )
return;
// unhook this function to prevent infinite looping
remove_action( 'save_post', 'set_custom_permalink', 10, 3 );
// update the post slug
wp_update_post( array(
'ID' => $post_id,
'post_name' => 'my-custom-slug', // Replace with function to generate Slug
) );
// re-hook this function
add_action( 'save_post', 'set_custom_permalink', 10, 3 );
}
Schreibe einen Kommentar