Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

  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.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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