rewrite - Trouble with Wordpress multiple custom querystrings -
i'm working on adding multiple querystring , doesn't seem work. i've found codes seems work others might i'm missing something.
i want like:
http://mydomain.com/board/?getyear=2013&getsometext2=sometext
to
i added code below functions.php
file. doesn't seem work should though.
this works. echoing querystring gets both variable without problem.
but doesn't. tested querystring vis isset()
seems nothing being set/get
function add_query_vars($vars) { $vars[] = "getyear"; $vars[] = "getsometext2"; return $vars; } add_filter('query_vars', 'add_query_vars'); function add_rewrite_rules($arules) { $anewrules = array('board/([^/]+)/([^/]+)/?$' => 'index.php?pagename=board&getyear=$matches[1]&getsometext2=$matches[2]'); $arules = $anewrules + $arules; return $arules; } add_filter('rewrite_rules_array', 'add_rewrite_rules');
any appreciated.
thanks!
as expected, missing rewrite rule when second parameter not used. answer code worked me:
function add_rewrite_rules($arules) { 'board/(.*)/(.*)/?' => 'index.php?pagename=board&getyear=$matches[1]&getsometext2=$matches[2]', 'board/(.*)/?' => 'index.php?pagename=leaderboard&getyear=$matches[1]'); $arules = $anewrules + $arules; return $arules; }
hope finds useful.
Comments
Post a Comment