wordpress - Virtual Page Within Theme Template -


i creating plugin needs virtual page in order dynamically create "review order" page (orders custom post type created). able create virtual page using following code:

// set rewrite rules 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 ) ) {      //beginning of page code      echo "hello";     exit;   } } 

the problem creates page blank template, is, above code creates blank page text hello. virtual page within theme of site , displayed regular page within wordpress framework. how accomplish this?

a solution add template page inside parse_request:

function action_parse_request( $wp ) {     if ( array_key_exists( 'virtual', $wp->query_vars ) ) {         get_header(); ?>             <div id="primary">             <div id="content" role="main">                     hello, world!                 </div>         </div>         <?php get_footer();         exit;     } } 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -