WordPress – SEO Title Tag too long

How to fix the error that the WordPress SEO Title Tag is too long.

If you automatically import products into WordPress you can’t really control the content.

Therefore i had to limit the amount of characters to keep a good SEO rating.

Solution:

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
        <head>
                <meta charset="utf-8">
                <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
                <meta http-equiv="X-UA-Compatible" content="IE=edge">
                <title><?php $title = wp_title("", false); if(strlen($title) > 70) { $title = substr($title, 0, 70); } echo $title; ?></title>
                <?php wp_head(); ?>

Search for the header.php file (or whatever the theme is using as a header file).

There you can place a php code which calculates the string length of the title tag and also cuts it if it is too long.

Caution:

You have to use the parameter false at the wp_title function.

If you don’t do that, the title tag is taking some strange values.

Kommentar verfassen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Scroll to Top