Skip to main content
2 of 4
added 273 characters in body

How to create a template for a custom URI associated with the user

I am working on a site where I am using a plugin called Favorite Posts so logged-in users can add a post (a custom post type) to their favorites.

I created a page called my-favorites which allows the logged-in user to see the posts he has favorited.

Now I need to create a page which allows the another user or visitor to check this user's favorites.

So I need to do three things:

  1. get a function related to author that returns a link like mydomain.com/user/username which I can append to /favorites to get the link- mydomain.com/user/username/favorites

  2. get wordpress to use a template called favorites.php to display this page.

  3. get the user id of the user in order to show his/her favorites to the visitor. right now i use the [favorite-post] shortcode in my template file and can pass a parameter called [favorite-post user_id = ""]

I found this article but it still deals with custom post types and query_vars which I am not using. How do I make it work for the favorites page? Most other similar questions asked here were solved using a slug for the custom post type or taxonomy.