I am trying to add some HTML to the title label in the backend of WordPress.

Attempt 1:

I am using the following (simplified) function:

function change_post_titles() {
    global $post, $title, $action, $current_screen;

    $title = 'foo<br>bar';
add_action('admin_head', 'change_post_titles');

This works in the way that the label of the title field is indeed changed, however the HTML tags get encoded afterwards. This mean that the label looks like:


Instead of:


Encoded HTML

Attempt 2:

I also tried using a gettext filter, but that just completely filters (removes) the HTML.

add_filter('gettext', 'change_post_titles');
function change_post_titles( $translated_text, $text, $domain ) {
    return $translated_text = 'foo<br>bar';

Removed HTML

Is there any way to change the title label (programmatically) in a way I can add HTML?

  • 2
    I don't think so. If you search wp-admin/*.php for add-new-h2 (the class of the button afterwards) you'll see that the pages that use the title always render it as echo esc_html( $title );.
    – Rup
    Jul 29, 2014 at 17:37

2 Answers 2


It is not possible to add HTML to it.

For example, wp-admin/edit.php uses the following code:

<h1 class="wp-heading-inline">
echo esc_html( $post_type_object->labels->name );

As you can see, this uses the esc_html() function. This prevents you from adding html code. This works this way for security reasons.

function change_post_titles() {
    global $post, $title, $action, $current_screen;
    $title = "foo<br>bar";
    $title = str_replace('<br>', ' ', $title);
add_action('admin_head', 'change_post_titles');

Use this this will give the result you want. Please check it let me know for any doubts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.