Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End wordpress – link to file at root level Re: wordpress – link to file at root level

#82311
fishnfrogs
Member

Thanks everyone. I was trying to keep it at a theme level for reasons I don’t quite understand. Anyway, I installed the Humans TXT plugin and reversed it to do what I wanted. Turns out I was looking for ‘template_redirect’ and some added code:


add_action('init', 'addHowdy');
add_action('template_redirect', 'howdy_template_redirect', 8);

function addHowdy() {

global $wp_rewrite;

$rewrite_rules = get_option('rewrite_rules');

add_filter('query_vars', create_function('$qv', '$qv[] = "howdy"; return $qv;'));
add_rewrite_rule('howdy.txt$', $wp_rewrite->index.'?howdy=1', 'top');

flush_rewrite_rules(false);

}

function is_howdy() {
return (bool)get_query_var('howdy');
}

function howdy_template_redirect() {
if(is_howdy())
{
load_template( TEMPLATEPATH . '/utils/howdy.php');
exit();
}
}

It seems to work and I can’t say it’s the most efficient, but it works for what I need. Thanks for everyone’s replies!!