# bbPress: Allow Headings and Code Blocks in Posts

> Lets forum members use more formatting in topics and replies, such as headings, preformatted code blocks and tables, which is handy for technical forums.

- Type: PHP
- Runs: Run everywhere
- Category: [Users](https://wpide.com/library/category/users/)
- Tags: bbpress, formatting, html
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/bbpress-allow-code-tags/

## Code

```php
if ( ! function_exists( 'bbp_kses_allowed_tags' ) ) {
    return;
}

add_filter( 'bbp_kses_allowed_tags', function ( $tags ) {
    foreach ( array( 'h3', 'h4', 'pre', 'table', 'thead', 'tbody', 'tr', 'td', 'th', 'kbd', 'hr' ) as $tag ) {
        if ( ! isset( $tags[ $tag ] ) ) {
            $tags[ $tag ] = array();
        }
    }

    $tags['code'] = array( 'class' => true );

    return $tags;
} );
```

## Notes

Only harmless formatting tags are added; no scripts, styles or attributes that could be abused.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "bbPress: Allow Headings and Code Blocks in Posts" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
