Allow HTML in WordPress Author Bios
templates, wordpress
If you are regular reader of this site than you know I change the theme about as often as I change my socks. This site is more than a marketing and design resource for my readers, it is also a design and usability testing playground for me! And as you may have noticed, the site has undergone a few new layout changes today.
There is one in particular change that I would like to discuss further, adding an author bio to post pages. While this is not in itself a difficult change or anything that would normally warrant a post, I had to make a minor change to the core WordPress code to allow HTML markup in the author bio field.
I wanted to add an author box below my posts that included the author bio from the administration area, but I wanted to use HTML in the bio. When I first tried to add HTML to my bio, I found that HTML markup is stripped when by WordPress by default. This default action by WordPress made it impossible to add links and images or other rich content to the biography field for authors.
To solve this problem, I found a bypass that will allow WordPress to accept HTML markup in the bio.
To do this, you need to open and edit the file: /wp-includes/registration.php
Do a search for the following line of code:
$description = apply_filters(‘pre_user_description’, $description);
You need to comment out that line. This is done by adding a // to the start of the line, like this:
//$description = apply_filters(‘pre_user_description’, $description);
This will stop WordPress from filtering out your HTML in the author bio field.
Next, you will need to add a caller to your template that pulls the author description. To do this, simply add the following line of code to your template where you wish to display the author bio content:
<?php the_author_description(); ?>
In my case I placed this line within a SPAN that I styled to match the appearance of my site.
You can see it in action below!







Nice! Great addition to the end of a post, especially for people landing on a page inside your site and visiting for the first time, like myself. Saw a tweet about this and had to check it out.
Dan Gorgone’s last blog post… Don’t Design (for the Mobile) Like It’s 1999
Comment by Dan Gorgone — February 18, 2009 @ 2:38 pm
Thanks for stopping by… Glad to see a new reader around here!
Comment by zacheos — February 18, 2009 @ 2:50 pm
[...] forum responder linked to an off-site solution suggesting that a core WordPress file be manipulated. As always, every effort should be made to [...]
Pingback by Allow Full HTML in WordPress User Bio Description » BLOG INGENUITY — May 14, 2009 @ 9:17 pm
Thanks for the post! I was just looking for this solution to embed videos to our authors bios.
Sal B’s last blog post… The Creative Brain Trust
Comment by Sal B — May 29, 2009 @ 12:34 pm
Awesome idea… I had not thought of that!
Comment by zacheos — May 29, 2009 @ 12:50 pm
is there not a way to accomplish this without editing the core files, like through functions.php or something?
Tammy Hart’s last blog post… WordPress: How to Use Categories as Your Navigation Bar
Comment by Tammy Hart — June 1, 2009 @ 12:21 am
Thanks for the tip Zach! It really helps me.
Raphael’s last blog post… Une bonne idée pour contourner la loi Evin
Comment by Raphael — June 6, 2009 @ 4:03 am
I cannot thank you enough! I lost so much time searching for an answer to this! Thanks a ton!
Comment by Jake — June 25, 2009 @ 6:41 pm
I’m not sure this is the best way to fix the problem… when you update wordpress to a new version, for example, registration.php will be replaced and the functionality will revert to stripping tags.
A better way is to use the WordPress Filter API. By default, wordpress uses a function called “wp_filter_kses” to strip potentially harmful content out of user descriptions (i.e., to prevent XSS attacks). You can find this by searching for ‘pre_user_description’ in the file wp-includes/default-filters.php.
You have two options:
1. Completely remove this functionality. This may be dangerous, but only if you let the general public create wordpress accounts, which it doesn’t look like you do. To do this, you can add the following to functions.php:
remove_filter(‘pre_user_description’, ‘wp_filter_kses’);
2. Modify the allowed tags to include the ones you want to use. This will also modify rules for HTML tags in comments. There is plenty of info about this in google.
Comment by Taylor — June 30, 2009 @ 11:52 am
There is a way, using functions.php as you guessed. I wrote a short article about using functions.php to allow full HTML in user bios.
Credit goes to Zach for spurring the research that lead to that code.
Adam’s last blog post… Author Exposed Reloaded Plugin – Tonight’s Updates
Comment by Adam — June 30, 2009 @ 9:20 pm
Don’t have time to read the blog daily? ,
Comment by Barbara15 — October 23, 2009 @ 6:19 am
I have just done as suggested and now when I try and edit a user I get a white blank screen.
I took a backup of the file before changing and even putting in the backup file is still bringing up a white screen when trying to edit a user.
Anyone else seen this?
Comment by PG — January 18, 2010 @ 3:49 am
fantastic… i have solved my problem.
Comment by murali — March 9, 2010 @ 12:04 am
Thanks, this helped me add a sig box to my forum using the forum server plug in, can I make it so my users can just add an image URL with a [img]URLHERE[/img] sorta thing? also how would I add a image above everyone’s bio’s? hope u can help
Comment by Adam — March 9, 2010 @ 6:57 am