Skip Navigation

[Resolved] Show Author information on Author archive page

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

Problem: I would like to show information about the Author being shown in the Author archive page.

Solution: In most cases, the wpv-post-author shortcode is used to display information about the current Author. However in this site setup, the wpv-post-author shortcode does not behave as expected in the Author archive. This may be a result of the custom theme or another active plugin. Please add this custom shortcode to your theme's functions.php file:

function get_author_id_in_archive_func($atts) {
  $author_id = 0;
  if (is_author()){
    $author = get_queried_object();
    $author_id = $author->ID;
  }
  return $author_id;
}
add_shortcode("get_author_id_in_archive", "get_author_id_in_archive_func");

Go to Toolset > Settings > Frontend content and add "get_author_id_in_archive" in the "Third-party shortcode arguments" input field.

Then you can use the shortcode in your Author Archive Layout Visual Editor cell or WordPress Archive cell to supply the Author's User ID to a wpv-user shortcode:

Author ID: [get_author_id_in_archive]<br />
Author first name: [wpv-user id="[get_author_id_in_archive]" field="user_firstname"]<br />
Author last name: [wpv-user id="[get_author_id_in_archive]" field="user_lastname"]<br />
Author custom field: [wpv-user id="[get_author_id_in_archive]" field="wpcf-fieldslug"]<br />
Author profile picture: [wpv-user id="[get_author_id_in_archive]" field="profile_picture" size="100"]<br />

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

This support ticket is created 6 years, 10 months 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 13 replies, has 3 voices.

Last updated by tomS-10 6 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#612146
Skjermbilde 2018-02-02 kl. 11.57.11.png

I am trying to set up a page for each author. When somebody reads an article there should be a link to the author. This part works. But the text or layout for this landing page is what I am wondering about.

On this page the visitor should see the following:
- Profile Image
- Name
- Articles written by this person

How do I solve this problem?

The only thing I accomplished is to get informasjon about the CURRENT user. And this is not what I want.

Could you please mind helping me?

#612284

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Tom,

Thank you for contacting our support forum.

For some of the fields you will need to specify the user information that it should get.

So you need to add the id attribute to any shortcode thats not displaying the correct info and pass the author's id into it.

Example.


id = "[wpv-post-author format='meta' meta='ID']"

Please let me know if this helps.
Thanks,
Shane

#612664

Hello Shane,

Thank you for helping me out,

Would you please give me an example of how I should do this. E.g: How to show the featured image.

I guess it will be easier for me to understand this way.

#612834

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Tom,

So you're showing the profile image of the Author correct?

Could you send me the shortcode you are using to display this so that I can prepare the example.

Thanks,
Shane

#615887

Currently I am not showing anything correctly I am afraid of.

Here is what I have tried and nothing works:

[wpv-post-featured-image id="[wpv-post-author format='meta' meta='ID']"]<br />
[wpv-archive-title]<br />
[wpv-post-title]<br />
[wpv-current-user info="profile_picture"]<br />
[wpv-user field="user_url"]<br />
[wpv-post-type show="single"]<br />
[wpv-archive-title]
[wpv-archive-title id="[wpv-post-author format='meta' meta='ID']"]
[wpv-user field="display_name"]/[wpv-post-author]
[wpv-post-author format="meta" meta="first_name" id="[wpv-post-author format='meta' meta='ID']"]

Any ideas?

#616067

Hi, Shane is unavailable today so he asked me to take this ticket. I hope that's okay with you. I can see from your screenshot that you have created a Layout for Author Archives. Then you have several shortcodes in a Visual Editor cell that do not seem to work as expected. Let me explain what is happening.

[wpv-post-featured-image id="[wpv-post-author format='meta' meta='ID']"]<br />
[wpv-post-title]<br />
[wpv-post-type show="single"]<br />

These shortcodes are all related to posts, you can tell because they all begin with "wpv-post-". Since this page is an Author archive, these shortcodes may not work as expected outside the Loop of posts. Outside the Loop, the context is the Author User, so wpv-user shortcodes should be used to show information about the Author, in general.

[wpv-archive-title]

This shortcode works as expected, and should say something like "Author: username". If you see something else, we can investigate further.

[wpv-archive-title id="[wpv-post-author format='meta' meta='ID']"]

Not quite sure what you're trying to do here, but the id attribute is not supported in the wpv-archive-title shortcode:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-archive-title

[wpv-current-user info="profile_picture"]<br />

This shortcode will show the profile of the current logged-in User, not the profile pic of the Author represented in the current archive.

[wpv-user field="user_url"]<br />
[wpv-user field="display_name"]/[wpv-post-author]

Please refer to the documentation for the wpv-user shortcode:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-user

...Otherwise it will display information for the current logged-in user or the user with the specific id, when id attribute is set.

In other words, you must pass the Author's User ID into the wpv-user field if you want to get information about the Author User. You should be able to use the wpv-post-author shortcode to get that ID. This is the only wpv-post- shortcode that I recommend using outside the Loop of posts in an Author archive.

Putting it all together:

Archive title: [wpv-archive-title]<br />
Author ID: [wpv-post-author format="meta" meta="ID"]<br />
Author first name: [wpv-post-author format="meta" meta="first_name"]<br />
Author last name: [wpv-post-author format="meta" meta="last_name"]<br />
Author custom field: [wpv-user id="[wpv-post-author format='meta' meta='ID']" field="wpcf-fieldslug"]<br />
Author profile picture: [wpv-user id="[wpv-post-author format='meta' meta='ID']" field="profile_picture" size="100"]<br />
#617679

Hello,

Thanks for getting back to me. Sorry for my confusing question, but I am trying to set up a page for each author. When somebody reads an article there should be a link to the author. This part works. But the text or layout for this landing page is what I am wondering about.

On this page the visitor should see the following:
- Profile Image
- Name
- Articles written by this person

E.g:
hidden link
hidden link

Hope this helps understanding my question,

#618032

But the text or layout for this landing page is what I am wondering about.
Yes, this is what I am talking about as well. These author URLs (e.g. /author/higraf) are generated by WordPress, and are intended to hold archives of posts by each author. Toolset lets you control the design of the landing pages at these URLs using WordPress Archives and Layouts. Place these shortcodes in a Visual Editor cell in the Layout you currently have assigned to Author Archives:

Author profile picture: [wpv-user id="[wpv-post-author format='meta' meta='ID']" field="profile_picture" size="100"]<br />
Author name: [wpv-post-author format="meta" meta="first_name"] [wpv-post-author format="meta" meta="last_name"]<br />

Then visit an author archive on the front-end. You should see their profile picture and name appear. Next, typically you will place a WordPress Archive cell in this Layout instead of a View. The WordPress Archive is where the posts by the current author will be displayed. You can design the style of each post in the Loop Output of this WordPress Archive. I see that you have a View cell included in your Layout. Unless you have a good reason for placing a View here, I recommend removing this and replacing it with a WordPress Archive.

#618139

Thank you Christian Cox,

I changed the View to a WordPress Archive cell, and that solved that problem. However, the incorrect image and no author name comes up using

Author profile picture: [wpv-user id="[wpv-post-author format='meta' meta='ID']" field="profile_picture" size="100"]<br />
Author name: [wpv-post-author format="meta" meta="first_name"] [wpv-post-author format="meta" meta="last_name"]<br />

Not sure where I do wrong thing: hidden link

#618401

May I log in to your wp-admin area to see how things are set up? I will activate private reply fields here.

#618487

Okay thanks, I don't see anything obviously wrong here. Can I create a clone of your site so I can install it locally and run some tests? I will install the Duplicator plugin to create a clone. This way I can make changes without causing problems on your live site.

#618530

Thank you Christian. Yes, feel free to do that. The site has alot of traffic, so we can`t take it down.

#618800

Strange, I'm not quite sure why there is a difference on your site but I have a solution that fixes the issue in my local clone. Please add this custom shortcode to your theme's functions.php file:

function get_author_id_in_archive_func($atts) {
  $author_id = 0;
  if (is_author()){
    $author = get_queried_object();
    $author_id = $author->ID;
  }
  return $author_id;
}
add_shortcode("get_author_id_in_archive", "get_author_id_in_archive_func");

Go to Toolset > Settings > Frontend content and add "get_author_id_in_archive" in the "Third-party shortcode arguments" input field.

Then you can use the shortcode in your Author Archive Layout Visual Editor cell or WordPress Archive cell to supply the Author's User ID to a wpv-user shortcode:

Author ID: [get_author_id_in_archive]<br />
Author first name: [wpv-user id="[get_author_id_in_archive]" field="user_firstname"]<br />
Author last name: [wpv-user id="[get_author_id_in_archive]" field="user_lastname"]<br />
Author custom field: [wpv-user id="[get_author_id_in_archive]" field="wpcf-fieldslug"]<br />
Author profile picture: [wpv-user id="[get_author_id_in_archive]" field="profile_picture" size="100"]<br />
#619898

Thank you Christian,

Problem is solved.