2

Assuming I have this URL:

http://site.com/?get=something

How can I change it to a nice URL that looks like:

http://site.com/get_something

using WP's URL rewriting system?

1 Answer 1

1

First add get to query vars array:

function add_query_vars_wpa12572($vars) {
    $vars[] = 'get'
    return $vars;
}

add_filter('query_vars', 'add_query_vars_wp12572');

then add the rewrite rule

function author_rewrite_rules_wpa12572( $wp_rewrite ) {
  $newrules = array();
  $new_rules['get_(\d*)$'] = 'index.php?get=$matches[1]';
  $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
add_filter('generate_rewrite_rules','author_rewrite_rules_wpa12572');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.