Stephanie Leary

Writer and WordPress consultant

  • Books
    • Content Strategy for WordPress (2015)
    • WordPress for Web Developers (2013)
    • Beginning WordPress 3 (2010)
  • Blog
    • Fascism Watch (2016-17)
    • Content Modeling for WordPress series
    • WordPress Hidden Gems series
  • Work
    • Portfolio
    • Services
    • WordPress Plugins
    • WordPress Themes
    • Presentations and Interviews
    • on GitHub →
  • About
    • Press Kit
  • Contact
    • Mailing List

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

Leave a Reply Cancel reply

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

Fascism Watch

The Fascism Watch is a daily(ish) news roundup. View all the previous Fascism Watch posts »

Latest WordPress Book

Content Strategy for WordPress

A short book for content strategists and managers on implementing a complete content strategy in WordPress: evaluation, analysis, content modeling, editing and workflows, and long-term planning and maintenance.

Read the sample chapter

Kindle Nook iBooks Kobo Smashwords

WordPress for Web Developers

WordPress for Web Developers (9781430258667)

This is a book for professional web designers and developers who already know HTML and CSS, and want to learn to build sites with WordPress. The book begins with a detailed tour of the administration screens and settings, then digs into server-side topics like performance and security. The second half of the book is devoted to development: learning to build WordPress themes and plugins.

This is the second, much-revised and updated edition of Beginning WordPress 3, with a more accurate title. Everything’s been updated for WordPress 3.6.

WordPress for Web Developers is out now. See what's inside...

The best WordPress features you’ve never noticed

  • WordPress Hidden Gems: Screen Options
  • WordPress Hidden Gems: Bulk Edit
  • WordPress Hidden Gems: Private Status
  • WordPress Hidden Gems: Dashboard Feed Readers
  • WordPress Hidden Gems: Options.php

Content Modeling for WordPress series

  • Content modeling for WordPress, part 1: analyze content
  • Content modeling for WordPress, part 2: functional and organizational requirements
  • Content modeling for WordPress, part 3: a sample content model

This is an excerpt from Content Strategy for WordPress.My latest books are Content Strategy for WordPress (2015) and WordPress for Web Developers (2013). Sign up to be notified when I have a new book for you.

Copyright © 2021 Stephanie Leary