By default, bbPress limits which HTML tags are allowed in the topics and replies content and even which HTML tag attributes are allowed. Only keymasters and moderators can post using expanded set of HTML tags and attributes.

By default, bbPress allows only some tags to be included, and for them only some of the attributes. So, you can’t use ‘class’ attribute for any of the tags, and you can’t use ‘style’ attribute too.

Custom Code

This example will add class and style attributes to some of the tags, and one new tag. You can expand it further with more tags and more attributes.

add_filter('bbp_kses_allowed_tags', 'bbhelp_club_kses_allowed_tags', 10000);

function bbhelp_club_kses_allowed_tags($list) {
  // modify IMG tag //
  $list['img']['class'] = true;
  $list['img']['style'] = true;

  // modify UL/OL tags //
  $list['ul']['class'] = true;
  $list['ul']['style'] = true;
  $list['ol']['class'] = true;
  $list['ol']['style'] = true;

  // add SPAN tag
  $list['span'] = array(
    'class' => true,
    'style' => true
  );
  
  return $list;
}

Using a plugin

If you don’t want to add custom code, you might wanna consider one of the plugins that can do this:

  • GD bbPress Toolbox Pro – this plugin has option to enable expanded list of HTML tags and attributes, or even enable full set of tags and attributes.
Please, take a few seconds and rate this answer
Rating: 5.0/5. From 2 votes. Votes Distribution.
Please wait...

Question answered by

Milan Petrovic

Programmer since the age of 12 and now WordPress developer with more than 8 years of WordPress experience, author of more than 100 plugins and more than 20 themes.

Dev4Press - Premium plugins for your WordPress and bbPress powered website.

The Comments

Leave a Reply

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

WP Rocket - Make WordPress Load Fast in a Few Clicks