Title tags can be easily changed via custom fields

Title tags are important for your website. Not only they will show up to users, but they will take an important role in your SEO. Choosing the right title tag can have a big impact on search engines and you can benefit from changing title tags if done correctly.

For a regular user, it is easy to change title tags simply by navigating to Settings -> General. Similarly, going to Appearance -> Customize will show a place where almost every theme will allow you to change your site’s title and tagline. Usually, websites use their title and post/page name, separated by one character. But you can change that if you want to be so rebellious.

With WordPress 4.4, new filters allowed you to change titles, taglines and separators more easily. In our last article, we showed you how to change title separator throughout your website. Today, we’re about to show you how to change titles.

Create a static title tag for all of your posts:

Although not recommended, you might want to change page title tag and make it the same on all of your WordPress posts and pages. Instead of using title, separator and post name, for example, you can change that into something static:

  1. Open functions.php file
  2. Copy and paste the following:
  3. function same_title_tag()
    return 'WP Loop';
    add_filter('pre_get_document_title', 'same_title_tag');
  4. Change the title on the 3rd line
  5. Save changes

This function would change every post and page title into “WP Loop” (hey, don’t use our name, be creative), but that’s acceptable if you’re about to have one page only. Instead, using default titles is a much better option when it comes to SEO and overall user experience. Even if you had only home and contact page, it’s still a better option to have that “contact” part written in the title tag.

Change title tags through custom fields:

But, let’s build upon this and give your authors possibility to add custom titles to their posts:

  1. Open functions.php
  2. Copy and paste the code:
  3. function post_meta_title_tag()
    $customPostTitleMeta = get_post_meta( get_the_ID(), 'custom_post_title', true);
    return $customPostTitleMeta;
    return '';
    add_filter('pre_get_document_title', 'post_meta_title_tag');
  4. Save changes
  5. Open a post for which you want to change title
  6. In custom field’s name, write “custom_post_title”
  7. In custom field’s value, write any title you want to use for that post
  8. Save changes/publish post

Now, instead of getting a default title, your post would use the custom one you have entered on the 6th step. If you leave out the custom field, WordPress will load default title tag and use it for that post.

If you don’t want your site to write taglines as part of your title, stay tuned because we’re about to show you how to remove taglines easily in one of our next posts.


This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

2 thoughts on “Title tags can be easily changed via custom fields

Leave a Reply

Your email address will not be published. Required fields are marked *