Hello friend, welcome to my blog post how to set custom page title for homepage WordPress. When we use a wp_title() function inside title tag and set a custom page template as a front page then we will see a blank page title in your page source code and see your domain name like www.example.com into your page title. So you need to set a custom page title for the homepage. So we can use WordPress filter hook to set page title. The wp_title filter is used to filter the title of the page (called with wp_title()). This filters the text appearing in the HTML title tag (sometimes called the “title tag” or “meta title”), not the post, page, or category title.

Set custom page title for homepage WordPress




A plugin (or theme) can register as a content filter with the below code:

Where ‘filter_function_name’ is the function WordPress should call when the content is being retrieved. Note that the filter function must return the content after it is finished processing, or the title will be blank and other plugins also filtering the content may generate errors.

You can also check How to enqueue inline scripts in header WordPress

filter_function_name should be unique function name. It cannot match any other function name already declared.

Set custom page title for homepage WordPress

Copy the code and paste it inside your theme functions.php:

In header.php:

Go to your website home page and refresh the page. Now you will see the changes.

Now you know how to set custom page title for homepage into your WordPress website. If you have any question or suggestion please comment below. If you like my post then please share it with your friends. Thank you.

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
How to set custom page title for homepage WordPress
Tagged on: