I have a WordPress page /users
and it displays a list of all users created. Each user has a link to its profile page. What I need to do is create that page. I want it to go like this /users/{user_id}-{first_name}-{last_name}
, for example – /users/1-john-doe
. I have a template for /users
and also for profile pages. Question – how do I properly make a page with that profile template so that it would have the url described above? The page does not need to select the user automatically, it needs to pass the user slug so I can read it in that page and query for that user (as a variable or something).
Thanks.
What you are looking for is the WordPress Rewrite API.
This allows you to define a new “endpoint” for your URL’s, and allows you to pick up the variable from the URL via built-in WordPress functionality.
A great article on it can be found here: Custom Endpoints