If you are a WordPress user, chances are good that you had to manage titles and their attributes before. Setting the perfect title isn’t just important for good exposure, but also essential for quality user experience and having them adhere to the design of your site.
In this guide, we’ll show you the easiest ways to adjust title attributes. This includes changing their length, adding separators and much more. You’ll learn how to make the headline perfectly fit your site, and maybe even improve SEO.
Contents
How to Adjust WordPress Page Titles
You may have created long titles for your WordPress blogs. However, in some cases, it is a good idea to shorten those titles. While you are working with more than one author, you may find it tough to do the task. Rather than leaving a big title that feels misplaced, you should consider removing it. Check this post to learn how to remove page or post titles. Additionally, there are plenty of other things you can do with them.
If you are running a business website or blog, it’s advisable to focus on the title as well as the number of characters in it. That’s something you should bear in mind every time you write your blog posts or create any other kind of page. First things first, take the time to adjust the length of titles.
How to Adjust Title Length
To adjust title length you’ll have to access the functions.php file of the theme you’re using. You can do this through the theme editor. There paste in the following code:
function max_title_length( $title ) { $max = 20; if( strlen( $title ) > $max ) { return substr( $title, 0, $max ). " …"; } else { return $title; } } add_filter( 'the_title', 'max_title_length');
You may position the function at any part of the theme. For instance, some website owners choose to have shorter titles on their homepage. While your title can include any number of characters your best bet is to keep it between 55 and 60.
How to Align the WordPress Post Title?
You already know that there are hundreds of WordPress themes available from both the official WordPress repository and third-party sources like ThemeForest.
Even if you have chosen a high-quality premium theme for your site, you will not be able to add every element to the finely tuned pages. When you think of altering the post title alignment you might find the option by clicking on the element, however, there might be no option to do so for your theme. Then you can apply the DIY method – altering some code.
Here’s how to do it on the single.php file, by using the WordPress theme editor:
- Go to the Appearance tab; from there, you should click on the Theme Editor.
- Open your Single Post
- Browse the file and find <?php the_title(); ?>. Then, alter the tag for your preferred alignment type.
Here’s the code snippet that allows you to align to the right:
<div align="right"><?php the_title(); ?></div>
This is how it would look if you wanted to align to the left:
<div align="left"><?php the_title(); ?></div>
Once you aligned the title to your preference, you can open the WordPress post to identify the modification. If you followed the steps correctly, you will see the changes made in action.
Preventing Certain Words from Being Used in Post Titles
In addition to limiting the page title, there are more options that WordPress offers for adjusting the post title. Don’t be fooled into thinking that you can write just about anything.
There can be a few phrases and words you might wanted to avoid using in the title. They can be a brand name and any other type of word. Maybe there’s even a common type with your brand name that you want to avoid in the titles at all costs. Basically, you can add whatever you need to have the CMS help you by blocking the words from your list in titles. If the post title has any of the restricted words, WordPress will prevent users from publishing the post.
To create this function that would prevent authors from writing these words in the title you have to add the following function and list the words that should be blocked in this code snippet:
function titlerestriction($title){ global $post; $title = $post->post_title; $restrictedWords = "word1;word2;word3"; } add_action('publish_post', 'titlerestriction');
Make sure to replace “word1;word2;word3” with what you need to be blocked. Be sure to follow the same syntax, separating the words with a semicolon, otherwise, the function won’t work.
Paste this snippet in the functions.php file of your theme.
Title Separator and Title Tag – Are They Useful?
Before covering title separators let’s briefly overview title tags. Those are the little headlines you see on Google’s search results when you enter in a query.
The separator is a character that – as the name implies – separates the page and post names from the title. In the example, it is the << symbol. These separators can be punctuation, a symbol, and any other character intended for distinguishing different sections of your page title.
To add one you can use a plugin like Yoast SEO. Simply follow this easy to follow tutorial! Search engines may identify common title separators, including the angled quotes, hyphen, and dash.
Some people believe that every separator has a different effect on SEO. Others say they have no impact on SERP results at all. Nevertheless, you may try altering the standard title using separators to improve how you represent the taxonomy of your site or how your titles are displayed. Be sure to choose the title separators that are most appropriate for your website. After all, there is no right option for all sites, and the decision is ultimately up to you.
Final Thoughts
You have gained some knowledge on how to deal with WordPress title attributes. Now that you have all the facts or information at your fingertips, it should be much easier for you to adjust titles so they perfectly fit your site and improve user experience, while giving you more control over your site’s design.
Adrian says
imho Ink for all is the best you can get. It is a text editor that has a wordpress plugin. I still like using yoast to double-check, but Ink for All is my absolute favorite.
Jackson says
It’s in 2020. Can anyone explain why rules-based plug-ins are still the norm? Especially because you can use free platforms with AI capabilities like INK for All
Adewale Tella Oluwasegun says
Good
Adewale Tella Oluwasegun says
Very good i need it.