add_filter('the_permalink')
, is the wrong tool for the job, it gets you the full permalink for the current post or a specific post ID.
It seems like the proper approach would be to use a rewrite rule:
add_filter('query_vars', function($vars){
$vars[] = 'id';
return $vars;
});
add_rewrite_rule('id\/([\w\-]+)\/?', 'index.php?id=$matches[1]', 'top');
CAVEAT: I haven’t tried this, and id
might be a reserved name in the rewrite rule.
But, this is the general idea for getting virtual subpages from a real parent page.