[Resolved] How to display user “biography” and category “description”?

Home Forums Support [Resolved] How to display user “biography” and category “description”?

Home Forums Support How to display user “biography” and category “description”?

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #1605924
    Anders

    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

    #1606246
    David
    Staff
    Customer Support

    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

    #1609392
    Anders

    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

    #1609420
    David
    Staff
    Customer Support

    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.

    #1609656
    Anders

    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

    #1609753
    David
    Staff
    Customer Support

    Aah – in the Display Rules tab of the Header Element you should see the Author Archives location

    #1609779
    Anders

    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.

    #1609805
    David
    Staff
    Customer Support

    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}}

    #1609939
    Anders

    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>

    #1610166
    David
    Staff
    Customer Support

    Can you provide temporary admin access to the site so i can take a look at what the issue is?

    #1610519
    Anders

    ok, thanks, see below

    #1610720
    David
    Staff
    Customer Support

    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

    #1610740
    Anders

    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)

    #1611061
    David
    Staff
    Customer Support

    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.

    #1611095
    Anders

    OK, thanks it works!

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.