[wp-trac] Re: [WordPress Trac] #2433: Provide some API for WP_Rewrite

WordPress Trac wp-trac at lists.automattic.com
Tue Feb 14 22:46:32 GMT 2006


#2433: Provide some API for WP_Rewrite
----------------------------+-----------------------------------------------
       Id:  2433            |      Status:  new                     
Component:  Administration  |    Modified:  Tue Feb 14 22:46:32 2006
 Severity:  normal          |   Milestone:  2.1                     
 Priority:  normal          |     Version:  2.0.1                   
    Owner:  anonymous       |    Reporter:  davidhouse              
----------------------------+-----------------------------------------------
Comment (by ryan):

 index.php can handle anything directed to it.  Just use the
 template_redirect action coupled with a query var.

 {{{

 function myplugin_template_redirect() {
         // Get tmy_var from WP_Query.
         $my_var = get_query_var('my_var');

         // If it's empty, return.
         if (empty($my_var))
                 return;

         // Otherwise, load our template.
         // You must use load_template rather than require or include.
         // load_template() sets up the necessary environment.
         load_template(ABSPATH . 'my_handler.php');
         // Make sure you exit after loading a template.
         exit;
 }

 add_action('template_redirect', 'myplugin_template_redirect');


 }}}

-- 
Ticket URL: <http://trac.wordpress.org/ticket/2433>
WordPress Trac <http://wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list