Newbie WordPress developer here.

I need to map a WordPress URL like this www.example.com/user/Username to a search result based on that Username

I already have the page that makes the search with the url www.example.com/search-results/?name=Username

In the functions.php I have

add_action( 'init', 'add_username_rules' );
function add_username_rules()
    global $wp_rewrite;



But this is not working and the rule is going to non_wp_rules.


That's going to the non wp rules because you're not mapping the URL to the index.php page format.

If you want it to be a WP rule, then you need to start the destination with index.php and include the query string to define what you want the query to contain.

So if you wanted it to go to a specific Page, for example, then you could set it as:


WordPress rewrite rules map the "pretty" url formats into the "default" url formats only. They're not full implementations of the htaccess rewrite system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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