Using short titles to stay focused on SEO, this snippet of code will limit the number of words allowed in the title of your post or page. You can set the number of words to whatever you wish – in this example, the maximum number of words is set to 8.
function maxWord($title){ global $post; $title = $post->post_title; if (str_word_count($title) >= 8 ) //set this to the maximum number of words wp_die( __('Error: your post title is over the maximum word count.') ); } add_action('publish_post', 'maxWord');
Adding this code to your functions.php file could help your SEO to keep the title focussed to the keyword in hand.
Why are short titles important for SEO?
If you are looking to optimise your page or post to rank for a certain keyword on Google or Bing etc. – you need to ensure word density isn’t changed to manipulate this. Instead, the optimum word density is where the content makes sense to an end-user reading your content. Having short and concise titles not only allows you to focus your content but it also immediately identifies if the content is relevant for a reader.
Is there a maximum title length?
There is no set title length – however, for SEO purposes it is generally considered that 60-65 characters are the most you should use. Any more characters in your title and you may see the title get truncated in the search results meaning users aren’t able to read the full title.