add_query_vars and add_rewrite_rules

I am looking for some clarity on what add_rewrite_rules does.

If I type in, or submit variables from a form, is it supposed to change the query variables to the pretty url?

Read More

Currently when I type in the pretty url, the page acts how I want. When I submit a form which redirects to a page with the query variables in the url, it also works fine. But I had thought that if I had typed in a url with the query variables, it would switch to the pretty url. It does not do that. Should it? Am I doing this wrong?

function add_query_vars($aVars) {
    $aVars[] .= 'var_state';
    $aVars[] .= 'var_clubs';
}
add_filter('query_vars', 'add_query_vars');

function add_rewrite_rules($aRules) {
    $aNewRules = array(
        'rv-clubs/([^/]+)/([^/]+)/?$' => 'index.php?pagename=rv-clubs&var_state=$matches[1]&var_clubs=$matches[2]'
    );
    $aRules = $aNewRules + $aRules;
    return $aRules;
}
add_filter('rewrite_rules_array', 'add_rewrite_rules');

Any help would be appreciated.

Related posts

Leave a Reply

1 comment