How to Change the Page Title on the Browser Tab

Overview

Would you like to change the page title of the browser tab on Conversational Forms? This is very easy to do with a small snippet of code. We’ll show you the PHP needed to change this title.

Setup

By default, when viewing the Conversational Forms, the page title that displays in the browser tab is pulled from the form name. In some cases, you may wish to make the browser tab title different to the actual name that displays when you load the form. To change this title, copy this code snippet to your site.

/**
 * Change the title on the browser tab.
 * 
 * @link https://wpforms.com/developers/how-to-change-the-page-title-on-the-browser-tab/
 *
 */

add_filter( 'pre_get_document_title', 'generate_custom_title', 100500 );
function generate_custom_title($title) {
if ( is_single('850') ) {
$title = __( 'My Custom Title', 'textdomain' );
}
return $title;
}

In the code shown above, the form ID we’re targeting is 850. You’ll need to change this ID number to match your form ID.

And that’s it! You’ve successfully changed the title of the browser tab shown on Conversational Forms. Would you like to also change the required field indicator on WPForms? Check out our tutorial on How to Change Required Field Indicator.

FAQ

Q: Will this work on Form Pages as well?

A: Absolutely! The code above will work for both Conversational Forms and Form Pages. Just remember to update the is_single('850') to match your own form ID.