Site logo

Archived topic

How to create line breaks in the Author Box text.

8 replies · Started by Jodie on February 9, 2020

Viewing posts 1–9 of 9

Hi guys

With your help I have this CSS in my additional CSS section in Customize.

/*START of Author Box */
.author-links a {
font-size: 3em;
line-height: 0.5em;
float: right;
}

.author-box {
padding: 4%;
margin-top: 60px;
font-size: 0.8em;
}

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

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

.author-summary {
overflow: hidden;
}
/* END of Author Box

The text I have is in the WP section for Biographical information for my profile.
I want to add line breaks so the text isn't in one big block. I have tried placing html in that Biographical information box but it is not picked up.

Have a look at the link I've given at the bottom of the post to see the Author box as it is now.

Any suggestions?

Thanks so much for your help as always.

Cheers
Jodie

Hi there,

how is the author box added ? Are you using the plugin or a hook element ?

Hi David. With a hook element as so

<?php
global $post;
$author_id = $post->post_author;
?>

<?php echo get_avatar( $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>

Try replacing:

<?php echo wp_kses( get_the_author_meta( ‘description’ ), null ); ?>

with:

<?php echo nl2br( get_the_author_meta( 'user_description' ) ); ?>

This won't display HTML such as <br /> tags but it should maintain any line breaks you have in the description

Thanks very much David, I will try that.

Cheers

Jodie

That worked. Thanks very much David.

Awesome - glad to hear that - i hadn't tested it so much appreciated i am sure it'll come in handy for others.

So glad I could help you guys out in the process of you helping me :)

Yes I hope it helps other too.

Cheers.

I am sure it will :)

This archived topic is closed to new replies.