I am working on a webinar plugin that uses a custom post type to display the webinar pages. Those pages could be register, thank you, countdown, live etc. depending on the visitors registration status and the current webinar status.
The plugin uses the template_include
action to render content based on the current post status and the visitors status (if they are registered or not).
The plugin lets users choose a custom page for one of those webinar pages, like a custom registration page or a custom thank you page. It shows the user a list of their WordPress pages and lets them choose one, then it saves the post_id
in wp_post_meta
.
In template_include
I’m getting the $custom_page_id
from wp_post_meta
and if it is set, I redirect the visitor to that page in template_include
using something like this:
$redirect_url = get_permalink($custom_page_id);
wp_redirect($redirect_url);
So the visitor accesses my custom post url:
https://example.com/my-post-type/mypost
And is then redirected to:
https://example.com/some-other-post
What I really want to do is render the entire contents of $custom_page_id
without redirecting and ideally pass in some meta data like the original post ID.
Is there any way I can render the full contents of $custom_page_id
(including theme header & footer) without having to redirect so the visitor stays on https://example.com/my-post-type/mypost
but sees exactly the same content as if they had redirected?