function site_url_handler($query)
{
$m = NULL;
// Manually parse the URL request
if(!empty($_SERVER['REQUEST_URI']))
{
$urlvars = explode('/', $_SERVER['REQUEST_URI']);
}
if(!empty($urlvars[1]) && $urlvars[1] == 'alias' && empty($urlvars[2]))
{
add_filter('template_include', array(&$this, 'my_template'));
}
}
add_action('init', function(){
add_rewrite_tag('%tax%', '([^&]+)');
add_rewrite_tag('%tags_name%', '([^&]+)');
add_rewrite_rule('^tags/([^/]*)/([^/]*)/?$', 'index.php?tax=$matches[1]&tags_name=$matches[2]', 'top');
});
add_filter('template_include', function($template){
global $wp_query;
if(!empty($wp_query->query_vars['tags_name']) && !empty($wp_query->query_vars['tax'])){
$wp_query->is_tax = true;
$slug = $wp_query->query_vars['tags_name'];
$tax = $wp_query->query_vars['tax'];
$term = get_term_by('slug', $slug, $tax . '_tags');
if(!$term) return THEME_PATH . DIR_SEP .'404.php';
$wp_query->queried_object = $term;
$wp_query->queried_object_id = $term->term_id;
return THEME_PATH . DIR_SEP .'tags.php';
}
return $template;
});