Home Daily Marketing Tips About Me Work With Me

Marketing & Design Blog

Internet Marketing, SEO, Blogging, Social Media, Lead Generation and Analytics

Allow HTML in WordPress Author Bios

,

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!

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

14 Comments »

  1. 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

  2. Thanks for stopping by… Glad to see a new reader around here!

    Comment by zacheos — February 18, 2009 @ 2:50 pm

  3. [...] 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

  4. 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

  5. Awesome idea… I had not thought of that!

    Comment by zacheos — May 29, 2009 @ 12:50 pm

  6. 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

  7. 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

  8. 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

  9. 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

  10. 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

  11. Don’t have time to read the blog daily? ,

    Comment by Barbara15 — October 23, 2009 @ 6:19 am

  12. 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

  13. fantastic… i have solved my problem.

    Comment by murali — March 9, 2010 @ 12:04 am

  14. 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

RSS feed for comments on this post. TrackBack URL

Leave a comment

logo design brand development

We have simplified the typical logo ordering process, put you in direct contact with the artist, made getting additional branding products and websites easy, and rounded it all off with high quality printing services at fantastic rates... Learn more

website design development

We have made getting a completely dynamic website built on the WordPress content management system with a theme of your choice easy. We integrate your logo into the site design and offer great add-ons at amazing prices - giving you a range of choices on design and layout... Learn more

search engine optimization

We have expert SEO consultants ready to tackle any aspect of your search engine marketing and optimization needs. We take pride in the ability to custom build an Internet marketing campaign that is perfectly suited to your needs.... Read more


© Copyright 2003-2010 Zach Graeve and Expert Online Services, LLC. All Rights Reserved.
 Subscribe, RSS, Comments RSS, XML Sitemap, Privacy Policy