render a wordpress post manually from within a plugin

Viewed 16

the goal is to have an "alias-route" for an existing wordpress post, without redirecting to the post, but render it directly.

so far in my plugin i create a route with

add_action('init', function(){
   add_rewrite_rule('^my-alias$', 'index.php', 'top' );
});

add_action( 'template_include', function( $template ) {
  return WP_PLUGIN_DIR.'/template.php';
});

And inside template.php i would like to render a certain post using the current theme. Maybe there is also another way.

0 Answers
Related