Allow/Enable HTML Tags in WordPress Post Titles

This code snippet allows you to use and render HTML tags within your WordPress post titles.

By applying a filter to the title function, it decodes HTML entities so that tags like line breaks, spans, or bold text display correctly on the front-end instead of appearing as plain text code.

// Allow HTML tags to render in the title on the front-end
add_filter( 'the_title', 'allow_html_in_post_titles' );
function allow_html_in_post_titles( $title ) {
    return html_entity_decode( $title );
}