- This topic has 5 replies, 2 voices, and was last updated 6 months, 1 week ago by Ying.
September 15, 2022 at 8:23 am #2343953jhmattern
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:
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:
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!September 15, 2022 at 10:11 am #2344060YingStaffCustomer Support
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!September 15, 2022 at 10:26 am #2344070jhmattern
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):
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.September 15, 2022 at 11:37 am #2344104YingStaffCustomer Support
Ah I see what you mean, try change this line:
<?php echo wp_kses( get_the_author_meta( 'description' ), null ); ?>
<?php echo get_the_author_meta( 'description' ); ?>September 15, 2022 at 11:43 am #2344108jhmattern
That did it. Thanks so much!September 15, 2022 at 11:43 am #2344109YingStaffCustomer Support
No problem 🙂
- You must be logged in to reply to this topic.