How to add several custom parameters in permalink
-
I have the page with URL (i.e. http://mysite.com/test) based on defined template. I need to pass 2 parameters (‘v’ and ‘b’) to this page using permalink.
I add this code to functions.php:
<?php function add_my_var($public_query_vars) { $public_query_vars[] = 'v'; $public_query_vars[] = 'b'; return $public_query_vars; } add_filter('query_vars', 'add_my_var'); function do_rewrite() { add_rewrite_rule('^test/([^/]*)/([^/]*)/?$', 'index.php?pagename=test&v=$matches[1]&b=$matches[2]','top'); } add_action('init', 'do_rewrite'); ?>and this to template file:
echo get_query_var('v'); echo get_query_var('b');But when I try to access http://mysite.com/test/example1/example2/ I get 404 error. Where am I wrong?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘How to add several custom parameters in permalink’ is closed to new replies.