• Skip to primary navigation
  • Skip to main content
  • Skip to footer
  • Books
    • Content Strategy for WordPress (2015)
    • WordPress for Web Developers (2013)
    • Beginning WordPress 3 (2010)
  • Blog
    • Content Modeling for WordPress
    • WordPress Hidden Gems
    • Web Design
  • Work
    • MLIS Class Projects (2019-2022)
    • Portfolio (2002-2019)
    • Services
    • WordPress Plugins
    • WordPress Themes
    • Presentations and Interviews
    • on GitHub →

Stephanie Leary

Writer, WordPress consultant, recent MLIS grad

  • About
    • Press Kit
    • Presentations and Interviews
  • Contact Me

preserving HTML

February 19, 2010 Stephanie Leary Leave a Comment

Several of the description fields in WordPress will strip any HTML entered into them. You can preserve them with a little work, though.

User Descriptions

The biography field on the user profile page accepts a limited number of HTML tags — the same ones allowed in comments. If you need to create richer biographies for your users, you can preserve HTML by adding the following to your functions.php file:

remove_filter( 'pre_user_description', 'wp_filter_kses' );

Category, Tag, and Taxonomy Descriptions

The taxonomy description fields also prevent you from entering some HTML. To keep it, add this to functions.php:

remove_filter( 'pre_term_description', 'wp_filter_kses' );
remove_filter( 'term_description', 'wp_kses_data' );

Excerpts

As I’ve mentioned before, there is no easy way to filter the excerpt function to preserve HTML; the PHP strip_tags() function is part of the_excerpt(), and there’s no getting around it without recreating the function altogether1. That’s exactly what the Advanced Excerpt plugin does. Download and activate it, and your HTML stays right where you put it.

1 If you’d like to see the_excerpt changed to allow HTML, add a comment on this bug report.

WordPress bio, biography, categories, descriptions, html, Metadata, rich text, tags, taxonomy, Users and Roles

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Footer

My Books

I’m a front end developer at Equinox OLI, working on open source library software. I was previously a freelance WordPress developer in higher education. You can get in touch here or on LinkedIn.

Copyright © 2023 Stephanie Leary · Contact