Virtual Page Within Theme Template
-
I am creating a plugin that needs a virtual page in order to dynamically create an “Review Order” page. I was able to create a virtual page using the following code:
// Set up the rewrite rules for the order page
add_action( ‘init’, ‘action_init_redirect’ );
function action_init_redirect() {
add_rewrite_rule( ‘orders/?’, ‘index.php?orders=new’, ‘top’ );
}add_filter( ‘query_vars’, ‘filter_query_vars’ );
function filter_query_vars( $query_vars ) {
$query_vars[] = ‘orders’;
return $query_vars;
}add_action( ‘parse_request’, ‘action_parse_request’);
function action_parse_request( &$wp ) {
if ( array_key_exists( ‘orders’, $wp->query_vars ) ) {
echo “hello”;
exit;
}
}The problem is that this creates a page with a blank template, that is, the above code creates a blank page with the text “hello”. I would like for the virtual page to be within the theme of the site and displayed like a regular page within the WordPress framework. How is the best way to accomplish this?
- The topic ‘Virtual Page Within Theme Template’ is closed to new replies.