Site logo

[Resolved] Author information wont show

Home Forums Support [Resolved] Author information wont show

Home Forums Support Author information wont show

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #795893
    Matthias

    Hi i want a Author box below my post, it wont show the description and doesnt show the photo/gravatar i use as an author: I used this for it

    <?php

    global $post;

    $author_id = $post->post_author;

    ?>

    <?php echo get_avatar( get_the_author_meta( $author_id )); ?>

    <h5 class=”author-title”><?php printf( esc_attr__( ‘About %s’, ‘the author’ ), get_the_author_meta( ‘display_name’) );?></h5>

    <p class=”author-description”><?php echo wp_kses( get_the_author_meta( ‘description’ ), null ); ?></p>

    But it wont show the author description

    #796080
    Leo
    Staff
    Customer Support

    Hi there,

    Have you solved this?

    The topic is marked as resolved.

    #1108554
    Simone Longato

    Hi,

    I have the same problem in my web marketing blog https://www.magnetmarketing.it/blog/.

    I would like to show an Author informations (name, gravatar, description) box below my post.

    Can you help me please?

    #1109012
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You can:

    1. Add a Hook Element: https://docs.generatepress.com/article/hooks-element-overview/
    2. Set the hook to after_content
    3. Check the Execute PHP option
    4. Add this as the hook content:

    <div class="author-box">
        <div class="avatar">
            <?php echo get_avatar( get_the_author_meta( 'ID' ) ); ?>
        </div>
     
        <div class="author-info">
            <h5 class="author-title"><?php printf( esc_attr__( 'About %s', 'the author' ), get_the_author_meta( 'display_name') );?></h5>
            <div class="author-summary">
                <p class="author-description"><?php echo wp_kses( get_the_author_meta( 'description' ), null ); ?></p>
            </div>
     
        </div>
    </div>

    5. Set the Display Rules.

    Then, just add this CSS to your site:

    .author-box {
        padding: 4%;
        margin-top: 60px;
        font-size: 1em;
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
    }

    Hope this helps 🙂

    #1109446
    Simone Longato

    Hi Tom,

    thanks, it’s working!

    Is it possible add related posts below the single post too?

    #1109894
    Tom
    Lead Developer
    Lead Developer

    Related posts are more complicated. Any chance you can open a new topic and we’ll explore those options?

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