Site logo

[Resolved] How to put author image and author’s name in 2 columns?

Home Forums Support [Resolved] How to put author image and author’s name in 2 columns?

Home Forums Support How to put author image and author’s name in 2 columns?

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #1495092
    Shami

    I’ve added author box using custom elements and some css.

    It just has one problem, the author image doesn’t show up on the left side of the ‘author name.’ Also the author name doesn’t link to the author bio.

    It’ll need a little tweaking in the css.

    #1495296
    David
    Staff
    Customer Support

    Hi there,

    what code did you use to add the Author box ?

    #1495350
    Shami
    <div class="author-box">
        <div class="avatar">
            <?php echo get_avatar( get_the_author_meta( 'ID' ), 250 ); ?>
        </div>
        <div class="author-info">
            <h5 class="author-title" itemprop="author" itemscope itemtype="http://schema.org/Person">
                <span itemprop="name"><?php printf( get_the_author_meta( 'display_name') );?></span>
            </h5>
            <div class="author-summary">
                <p class="author-description"><?php echo wp_kses( get_the_author_meta( 'description' ), null ); ?></p></div>
    <div class="author-links">
                <a>" title="Read more"></a>
           </div>
        </div>
    </div>

    I added the hook and selected generate_after_content.

    #1495353
    Shami

    Here is the CSS:
    /*for author box*/
    .author-box {
    background-color: #EFEFEF;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    padding: 4%;
    margin-top: 60px;
    font-size: 0.9em;
    -webkit-box-shadow: -1px 6px 11px 1px rgba(0,0,0,0.29);
    -moz-box-shadow: -1px 6px 11px 1px rgba(0,0,0,0.29);
    box-shadow: -1px 6px 11px 1px rgba(0,0,0,0.29);
    }

    .author-links a {
    font-size: 3em;
    line-height: 0.5em;
    float: right;
    }

    .author-box .avatar {
    width: 60px;
    border-radius: 100%;
    margin-right: 20px;
    }

    .author-description {
    line-height: 1.6em
    }

    h5.author-title {
    margin-bottom: 0.5em;
    }

    /*css for author box ends*/

    #1495452
    David
    Staff
    Customer Support

    In your code the <h5> element needs to move inside this:

    <div class="avatar">
        <?php echo get_avatar( get_the_author_meta( 'ID' ), 250 ); ?>
        <!--- move <h5> element here --->
    </div>

    Then we can align the image and the name.

    #1495818
    Shami

    I did that, but it now looks messed up.
    Looks like the css needs some adjustment.

    #1496168
    Tom
    Lead Developer
    Lead Developer

    I’m not seeing the change that David suggested on your site. Can you re-add it?

    #1496367
    Shami

    Yup. I changed it back as it was looking ugly. The author name was appearing in a vertical manner below the author gravatar. It needed css. And I didn’t know how to fix it. So to make sure user experience doesn’t get affected I changed it back.

    Sure. I’ve re-added it.

    Check again.

    #1496624
    David
    Staff
    Customer Support

    Change this line:

    <div class="avatar">

    to

    <div class="avatar-block">

    Then edit this CSS and include the height: 60px; property commented below :

    .author-box .avatar {
        width: 60px;
        border-radius: 100%;
        margin-right: 20px;
        height: 60px; /* Add this property */
    }

    Then add this CSS:

    .avatar-block {
        display: flex;
        align-items: center;
    }
    #1496675
    Shami

    Thanks David. It worked fine.
    One thing, though.
    It doesn’t link to the author’s page in the author’s name.
    It’d be great if that happened.

    #1497381
    Tom
    Lead Developer
    Lead Developer

    Replace this:

    <span itemprop="name"><?php printf( get_the_author_meta( 'display_name') );?></span>

    With this:

    <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>"><span itemprop="name"><?php printf( get_the_author_meta( 'display_name') );?></span></a>

    Let us know 🙂

    #1497818
    Shami

    Thanks Tom. It worked like a charm.

    #1497878
    Shami

    I was just wondering if it’s possible to add social share icons below the author box without using any plugin.

    #1498624
    Tom
    Lead Developer
    Lead Developer

    You can add anything you like as it’s custom HTML 🙂

    #1498732
    Shami

    Thanks for your advice. Just added some anchor text and it worked fine.

    Just one problem.

    My default links have underline below them. I want to remove that underline under all the links (only in the author box).

    CSS please.😃

Viewing 15 posts - 1 through 15 (of 20 total)
  • The topic ‘How to put author image and author’s name in 2 columns?’ is closed to new replies.