[wp-hackers] Integrate URLs from custom plugins?
Jennifer Hodgdon
yahgrp at poplarware.com
Sat Jun 2 00:00:25 GMT 2007
Boris Anthony wrote:
> I think what I am missing is understanding how to find the query vars I
> specify in my updated rewrite rules, further along the line, for example
> in a is_test() function (which I call to then send WP the test.php
> template.
Code something like this has worked for me to override template
selection based on what I got into the query variables with rewrite rules:
add_action('template_redirect', 'myplugin_template_override' );
function myplugin_template_override()
global $wp_query;
$template = '';
$q = $wp_query->query_vars;
if( isset( $q[ 'mycustomvariable' ] )) {
$template = TEMPLATEPATH . "/mycustomtemplate.php";
}
if( strlen( $template ) && file_exists( $template )) {
include( $template );
exit;
}
}
Hope this helps,
Jennifer
More information about the wp-hackers
mailing list