Site logo

Archived topic

Keep Wp Admin formatting when I display author box

7 replies · Started by Adrian on May 9, 2021

Viewing posts 1–8 of 8

Is it possible to display the author’s description using Dynamic Blocks by keeping the formatting in the wp-admin profile without having to use HTML?

The line breaks seem to be gone from displaying it this way. This was working fine before moving from Kadence to GeneratePress.

Hi Adrian,

Once you center the author image, you can give this CSS a try:

.gb-container.gb-container-de151b3d .gb-inside-container:before {
    content: "";
    background-color: #718096;
    height: 1px;
    width: calc(50% - 100px);
    position: absolute;
    left: 40px;
    top: 163px;
}
.gb-container.gb-container-de151b3d .gb-inside-container:after {
    content: "";
    background-color: #718096;
    height: 1px;
    width: calc(50% - 100px);
    position: absolute;
    right: 40px;
    top: 163px;
}

Let me know :)

I'm sorry that is not what I meant.

What I want is for the code to not get sanitized and displayed with the proper line spacing as it's in the WP Admin User Profile.

Using your Dynamic Block is great as it allows a lot more customization but it created this issue.

Here is the look on the User Profile: https://gyazo.com/702c8ff0943e5a8b6ff0d85b1e772f01

And the sanitized display that removes all the line spaces: https://gyazo.com/2f63c6e6d15107fa98bd6daa65762d84

This also happens in the author profile page: https://gyazo.com/b0955d70758ff0330b0d907234a76e2f

Thanks.

Hi there,

WP automatically strips any HTML from the Author Bio field ( user description ).
To stop that from happening you need to add the following PHP Snippet to your site:

remove_filter('pre_user_description', 'wp_filter_kses');

Adding PHP: https://docs.generatepress.com/article/adding-php/

Then you can enter HTML into the Author Bio eg.

<p>This is line one</p>
<p>This is line two</p>

Simply adding a line break will not infer a paragraph so you should include the HTML tags.

I am using a GeneratePress child theme.

In which file should I add that and where in the file?

Thank you.

It will go in your Child Themes functions.php it can be placed on a new line at the end of the file.

That only made HTML elements work.

I found this code that displays line breaks without requiring HTML in the user bio:

add_filter( 'get_the_author_description', 'tu_author_desc_autop' );
function tu_author_desc_autop( $output ) {
    return wpautop( $output );
}

Glad to hear that

This archived topic is closed to new replies.