add_rewrite
-
Hey guys I have this rewrite working but I was wondering if there was a way to get an infinite number of variables passed threw the url instead of having to set the rule over 20+ times
function plugin_add_custom_urls() {
add_rewrite_rule(‘(k)/([^/]+)/?$’,
‘index.php?pagename=$matches[2]’,’top’);add_rewrite_rule(‘(k)/([^/]+)/[/]?([^/]+)/?$’,
‘index.php?pagename=$matches[2]&var1=$matches[3]’,’top’);add_rewrite_rule(‘(k)/([^/]+)/[/]?([^/]+)/[/]?([^/]+)$’,
‘index.php?pagename=$matches[2]&var1=$matches[3]&var2=$matches[4]’,’top’);add_rewrite_tag(‘%var1%’, ‘[^/]+’);
add_rewrite_tag(‘%var2%’, ‘[^/]+’);
}// runs the function in the init hook
add_action(‘init’, ‘plugin_add_custom_urls’);
- The topic ‘add_rewrite’ is closed to new replies.