[Resolved] Display paragraphs in Author Bio hook

Home Forums Support [Resolved] Display paragraphs in Author Bio hook

Home Forums Support Display paragraphs in Author Bio hook

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2343953
    jhmattern

    I’ve set up a custom author bio as a hook:

    <div class="author-box" style="margin-top: 30px; border-top: #666666 1px solid; border-bottom: #666666 1px solid; padding-top:30px; padding-bottom:24px;">
        <div class="avatar" style="float:left; padding-right: 16px;"><?php echo get_avatar( get_the_author_meta( 'ID' )); ?></div>
    	<div class="author-title"><h3><a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>"><?php printf( esc_attr( '%s', 'the author'), get_the_author_meta('display_name') );?></a></h3></div>
        <div class="author-description" style="font-size:16px; line-height:1.2em!important; overflow:hidden;"><?php echo wp_kses( get_the_author_meta( 'description' ), null ); ?></div>
    </div>

    WordPress was stripping paragraph tags from the author bios though, so I added the following to Code Snippets, which I saw posted to another support thread:

    remove_filter('pre_user_description', 'wp_filter_kses');

    This is now leaving the P tags in the backend author bio area. But paragraphs are not being output to the front-end of the site. The bio is still being displayed as one large chunk of text, as seen below in a post here:

    https://freelancewritingpros.com/freelance-writing-gigs-from-ebooks/

    I’ve also tried the following in Code Snippets:

    // Disable WordPress sanitization to allow more than just $allowedtags from /wp-includes/kses.php.
    remove_filter( 'pre_user_description', 'wp_filter_kses' );
    // Add sanitization for WordPress posts.
    add_filter( 'pre_user_description', 'wp_filter_post_kses' );

    And I’ve tried setting both of those snippets to run just on the backend as well as sitewide. Both return the same results, leaving the html tags in the backend bio, but not inserting the paragraph spacing on the front-end.

    Any thoughts on how to get this hook to display proper paragraph tags?

    Thanks!

    #2344060
    Ying
    Staff
    Customer Support

    Hi there,

    For this issue, it’s better to reach out to WP support as the theme doesn’t have control over it.
    Thanks for your understanding!

    #2344070
    jhmattern

    I’m not sure how it could be a WordPress core issue. The paragraph tags are staying in the WP profile area like the code snippet is telling them to. The issue is that the GP hook is, for whatever reason, not “printing” what exists in the actual WP profile. That code was adapted from a version shared by support here in another thread (linked below):

    https://generatepress.com/forums/topic/customize-author-box/

    Customizations were to add inline styles, swap the author name P tag for H3, and changing the description P tag to a div to avoid created nested paragraph tags when the ones in the bio itself should be pulled in.

    UPDATE: I’ve also tried pasting in the exact code from that other support thread linked above. Same problem. The P tags appear in the WP profile area. But they’re not being pulled to the front-end by the hook element.

    #2344104
    Ying
    Staff
    Customer Support

    Ah I see what you mean, try change this line:
    <?php echo wp_kses( get_the_author_meta( 'description' ), null ); ?>

    to:
    <?php echo get_the_author_meta( 'description' ); ?>

    #2344108
    jhmattern

    That did it. Thanks so much!

    #2344109
    Ying
    Staff
    Customer Support

    No problem 🙂

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