I have created a page “profile” that when visited with get variable of user id like:

http://example.com/profile/?uid=1

Then it will display the profile details of user id 1. Now I want to rewrite …

http://example.com/profile/?uid=1 

… to …

http://example.com/profile/admin 

How to accomplish this?

1 Answer
1

  1. Create an endpoint for EP_ROOT named profile.
  2. In your callback handler use get_user_by( 'slug', get_query_var( 'profile' ) ) to find the user data.
  3. Create a template file profile.php and use locate_template( 'profile.php', TRUE ) to load it.
  4. In your template show the user data.

Leave a Reply

Your email address will not be published. Required fields are marked *