steeped
steeped

Reputation: 2633

Rewrite Query String in Wordpress URL

I am trying to rewrite a query string in Wordpress within the functions.php file, but it just isn't working. I'm probably making some dumb mistake, so any guidance is greatly appreciated!

I am trying to rewrite this URL: www.domain.com/car-lease-rate/?term1=true to www.domain.com/car-lease-rate/term1... or if possible www.domain.com/car-lease-rate/term/1.

add_action('init', 'add_my_rewrite');
function add_my_rewrite() {
    add_rewrite_rule('^car-lease-rate/term/([^/]+)','index.php?term1=$matches[1]','top');
}

Upvotes: 0

Views: 280

Answers (1)

Minh Quy
Minh Quy

Reputation: 665

You can try my code. I don't test it :p

add_action('init', 'add_my_rewrite');
function add_my_rewrite() {
    add_rewrite_rule('^car-lease-rate/term1/([^/]*)/?','index.php/car-lease-rate?term1=$matches[1]','top');
}

Upvotes: 1

Related Questions