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

http://mydomain.com/board/2013/sometext/

i added code below functions.php file. doesn't seem work should though.

this works. echoing querystring gets both variable without problem.

http://mydomain.com/board/2013/sometext/

but doesn't. tested querystring vis isset() seems nothing being set/get

http://mydomain.com/board/2013/

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

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

php - Accessing static methods using newly created $obj or using class Name -