- This topic has 19 replies, 4 voices, and was last updated 5 years, 6 months ago by
Leo.
-
AuthorPosts
-
October 19, 2020 at 12:44 am #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.
October 19, 2020 at 4:15 am #1495296David
StaffCustomer SupportHi there,
what code did you use to add the Author box ?
October 19, 2020 at 5:05 am #1495350Shami
<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.
October 19, 2020 at 5:07 am #1495353Shami
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*/
October 19, 2020 at 6:40 am #1495452David
StaffCustomer SupportIn 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.
October 19, 2020 at 9:16 am #1495818Shami
I did that, but it now looks messed up.
Looks like the css needs some adjustment.October 19, 2020 at 1:17 pm #1496168Tom
Lead DeveloperLead DeveloperI’m not seeing the change that David suggested on your site. Can you re-add it?
October 19, 2020 at 6:45 pm #1496367Shami
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.
October 20, 2020 at 2:18 am #1496624David
StaffCustomer SupportChange 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; }October 20, 2020 at 3:00 am #1496675Shami
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.October 20, 2020 at 9:53 am #1497381Tom
Lead DeveloperLead DeveloperReplace 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 🙂
October 20, 2020 at 8:02 pm #1497818Shami
Thanks Tom. It worked like a charm.
October 20, 2020 at 10:37 pm #1497878Shami
I was just wondering if it’s possible to add social share icons below the author box without using any plugin.
October 21, 2020 at 8:48 am #1498624Tom
Lead DeveloperLead DeveloperYou can add anything you like as it’s custom HTML 🙂
October 21, 2020 at 10:08 am #1498732Shami
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.😃
-
AuthorPosts
- The topic ‘How to put author image and author’s name in 2 columns?’ is closed to new replies.