Custom template redirect based on url vars
-
I am using a custom URL on my menu to show the most viewed posts by passing the variables to the url as
https://website.com/?v_sortby=views&v_orderby=desc
However I want to use a custom template to display the results.
I tried the following but it doest work. I am having trouble finding a fix, can anyone help.
function custom_template($template) { global $wp; if ($wp->query_vars['template']=='basic') { return dirname( __FILE__ ) . '/basic.php'; } else { return $template; } } add_filter('template_redirect', 'custom_template');
- The topic ‘Custom template redirect based on url vars’ is closed to new replies.