Archived topic
How to display user "biography" and category "description"?
15 replies · Started by Anders on January 4, 2021
Hi!
I submitted a topic about this yesterday, but it seems to have disappeared. Her it comes again:
I want some extra text on my Portfolio category archive page (category description).
https://simpliweb.se/category/portfolio/
and I want my user "biography" be displayed on my author archive page.
https://simpliweb.se/author/anders/
How to do? Or should I use the Elements? I tried to add a text in the Page Hero field but it did not show up.
See screenshots below
Hi there,
the Category description you can use this template tag:
{{custom_field.description}}
For the author Bio you will need to create a shortcode and add that to the header element, this article explains:
https://generatepress.com/forums/topic/adding-bio-to-author-page-and-adjustments/#post-1429130
Thanks it worked for category description but for the author bio I can not solve it. Where to put the shortcode? I tried different ways in the Element. Will the shortcode get the text from the wp admin user description field?
see screenshot
Did you add this code to your Site?
add_shortcode( 'author_bio', function() {
ob_start();
echo wp_kses( get_the_author_meta( 'description' ), null );
return ob_get_clean();
} );
This article explains how to add it:
https://docs.generatepress.com/article/adding-php/
The code will get that description from the User who is the author of that post, if thats the Admin then yes that will display their description.
Yes I added the code with the Code snippet plugin. But I am not talking aboud adding the bio to posts, I want it to be added to the author archive page
https://simpliweb.se/author/anders/
Right now I only get the avatar there
Aah - in the Display Rules tab of the Header Element you should see the Author Archives location
yes, I have chosen that. I still don't understand where to put the shortcode. I mean in your first reply you gave me this code {{custom_field.description}} and that doesn't work for Author archive page. So you mean I need to use a shortcode? Where to put the short code? See screenshots of my settings.
You would need to create a separate header element just for your Author Archives and then add the shortcode to the header elements content instead of: {{custom_field.description}}
sorry I still can't make it work
neither of these lines work
<h1>
{{post_title}}
</h1>
<p>
{{author_bio}}
</p>
<p>
[author_bio]
</p>
Can you provide temporary admin access to the site so i can take a look at what the issue is?
ok, thanks, see below
You have two separate header elements:
Arkivsidor search-author-date
Arkivsida Author
Both of these have the: Författararkiv display rule.
Header Elements - there can only be one ever displayed, if you have two with the same display rule, the header element that was published first will be displayed. Which is what is happening here.
In the Arkivsidor search-author-date remove the Författararkiv display rule. Then you should see the Arkivsida Author
Thanks, I thought I did that earlier but maybe it wasn't saved. Anyway, now, how to enter the shortode? I tried all possible combinations of brackets.
1.
<h1>
{{post_title}}
</h1>
<p>
[author_bio]
</p>
2.
<h1>
{{post_title}}
</h1>
<p>
{{author_bio}}
</p>
3.
<h1>
{{post_title}}
</h1>
<p>
{{[author_bio]}}
</p>
4.
<h1>
{{post_title}}
</h1>
<p>
[[author_bio]]
</p>
5.
<h1>
{{post_title}}
</h1>
<p>
{author_bio}
</p>
What appears on the author archive pages is:
Gravatar
Anders
[author_bio] (or whatever code I tried)
Option 1 ie.
<h1>
{{post_title}}
</h1>
<p>
[author_bio]
</p>
The issue: Go to Code Snippets and Active the Redigera kodsnutt snippet as its currently disabled.
OK, thanks it works!