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 be able to do three things:
Get a function related to author that returns a link like
example.com/user/username
which I can append to /favorites to get the link -example.com/user/username/favorites
(the_author_link()
andget_the_author()
link seems to link to the website andthe_author_posts_url()
outputs the a tag with the name. any function to just get the url or maybe modify author to show user instead?)Get WordPress to use a template called
favorites.php
to display this page. (If the structure matches, then how do I tell WordPress which template to use?)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 = ""]
Will it automatically get the user id if the page is branched out from /author?
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.