Skip Navigation

[Resolved] Author page template

This thread is resolved. Here is a description of the problem and solution.

Problem:
I need to show informations about a User on a User Single page. For example:
On /author/user1 I want to show user1 name and profile picture.
On /author/user2 I want to show user2 name and profile picture.

Solution:
1. Please add this code in your theme’s or child theme’s functions.php file:

 
function get_user_id() {
 $author = get_user_by( 'slug', get_query_var( 'author_name' ) );
 return $author->ID;
}
add_shortcode( 'get_user_id', 'get_user_id' );

2. Register the ‘get_user_id’ shortcode first in Toolset >> Settings >> Front-end Content >> Third-party shortcode arguments.

3. Then use shortcode like this in the Author Archive View:

[wpv-user field="user_login" id="[get_user_id]"]
[wpv-user field="profile_picture" id="[get_user_id]"]

WP Author Templates are below, currently we are talking about author.php:
https://codex.wordpress.org/Author_Templates#Which_Template_File_is_Used.3F

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-user

This support ticket is created 7 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 6 replies, has 2 voices.

Last updated by romanB-3 7 years, 1 month ago.

Assisted by: Noman.

Author
Posts
#560014

Hello,

I am trying to set up a Author template. Not a current user profile template, but a author template.

The page author/theauthor has the right title "The Author", and the right author ID in <body> class author-17

How can I display some info about the author with shortcodes like [wpv-user field="profile_picture"] ?

Thank you.

#560023

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

View for Author Archive.png

Hi Roman,

Thank you for contacting Toolset support. You can create a WordPress Archive View for Authors page, and insert User fields before loop section in Loop Output Editor, please see attached screenshot.

You can also create a Content Template and assign it to Author Archive page but I think WP Archive View works better in this case since Author page is actually an archive page or loop.

Thank you

#560055

I have done exactly what you said but now I still got same result : the shortcodes still return info about current user instead of user in the loop. [wpv-user field="display_name"]
Thank you.

#560070

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

post author.png

Hello Roman,

To display Post author name and profile picture please use Post Author option. See attached screenshot.

The shortcode will be like:

[wpv-post-author]
[wpv-post-author format="profile_picture" profile-picture-shape="square"]

Thank you

#560074

This is not what I am trying to achieve.

I don't need the current user ID, nor the post author ID.
I need to show informations about an user on a user single page.

On /author/user1 I want to show user1 name and profile picture.
On /author/user2 I want to show user2 name and profile picture.
Etc.

Thank you.

#560297

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Using wpv-user shortcode we can pass the user_id to it: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-user

1. Please add this code in your theme’s or child theme’s functions.php file:

function get_user_id() {
 $author = get_user_by( 'slug', get_query_var( 'author_name' ) );
 return $author->ID;
}
add_shortcode( 'get_user_id', 'get_user_id' );

2. Register the ‘get_user_id’ shortcode first in Toolset >> Settings >> Front-end Content >> Third-party shortcode arguments.

3. Then use shortcode like this in the Author Archive View:

[wpv-user field="user_login" id="[get_user_id]"]
[wpv-user field="profile_picture" id="[get_user_id]"]

WP Author Templates are below, currently we are talking about author.php:
https://codex.wordpress.org/Author_Templates#Which_Template_File_is_Used.3F

Thanks

#560303

Thank you so much ; that was it !

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.