I’m attempting to create a virtual page as a sub-page of an existing page and am having problems rendering the template.
The existing page lives at /apply/ and my subpage is going to be called confirm-email.
The final path then is /apply/confirm-email/
I’ve added a route for this using this code, hooked on init:
add_action( 'init', function() {
add_rewrite_endpoint( 'confirm-email', EP_ALL );
});
I’ve created a blade template at /views/confirm-email.blade.php.
It is a copy of other top-level templates:
{{--
Template Name: Confirm Email page
--}}
@extends( 'layouts.app' )
@section('content')
<h2>Confirm Form</h2>
@endsection
I’m getting this to display in a fashion with the following code hooked on template_redirect
add_action(
'template_redirect',
function () {
global $wp_query;
if ( ! is_page( 'apply' ) || ! isset( $wp_query->query_vars[ 'confirm-email' ] ) ) {
return;
}
echo \Roots\view( 'confirm-email' );exit;
}
);
I’m getting output when i visit /apply/confirm-email/ but it doesn’t include the full page wrappers - no doctype, opening html tag, head section down to the
I’m obviously doing this wrong and hoping someone can set me on a better path.