1. wordpress hook in construct()
function __construct() {
add_filter('post_type_link', [$this, 'custom_nft_permalink'], 1, 3);
}
2. rewrite post link
public function initialize() {
$args = array(
'rewrite' => array( 'slug' => 'custom_link/?id=%ID%/', 'with_front' => false ),
)
}
register_post_type( 'custom_post', $args );
3. trigger hook func to modify permalink
function custom_nft_permalink($post_link, $id = 0, $leavename) {
if ( strpos('%ID%', $post_link) === 'FALSE' ) {
return $post_link;
}
$post = &get_post($id);
if ( is_wp_error($post) || $post->post_type != 'custom_post' ) {
return $post_link;
}
$post_link = substr($post_link, 0, strpos($post_link, "%ID%"));
return $post_link.''.$post->ID;
}
4. Complete!

The permalink will be changed.
浙公网安备 33010602011771号