This is a serial strory of "SEO for WordPress Site": SEO for WordPress site [Part 1] - SEO for Posts-Articles - , SEO for WordPress site [Part 2] - SEO for Pages -, and this aritcle: SEO for WordPress site [Part 3] - SEO for Title -.
In this article, we guided how to do one of the Title-SEOs for your WordPress Site, without SEO plugins. The Title-SEO is like this:
, more specific, at the first step, create a PHP-file to display titles, and the next step, add the PHP-file to your header.php.
How to create the PHP-file to display titles
- （１）Create a new PHP-file in order to do the title-SEO. The name of the PHP-file is "header-custom.php".
- （２）Open your "header-custom.php", copyr the below and paste it to your "header-custom.php".
- （３）Change $Site_Title and $adding_text, and save your "header-custom.php".
- （４）In order to use your "header-custom.php" at your "header.php", copy the line below and paste it to your "header.php". At the upper place of </head> of your "header.php".
- To make your site-management-work easy, we recommend to line up the PHP-files for SEO like this:
You can set more conditions in each condition in "header-custom.php".
For example, at our WordPress Demo Site, we added conditions to the Front Page and to the Single Page. At the Single Page, if there are 2 words of "DEMO" or "デモ" in the titles, our $adding_text "Presented by RainbowLink Inc.（ 株式会社レインボーリンク ）" is displayed.
Add your specific conditions to your "header-custom.php" according to your SEO strategy.
If your WordPress displays empaty title tag in header.php, please do (A)(B) below.
(A) Open /wp-includes/general-template.php.
(B) Comment the line blow:
echo <title> . wp_get_document_title() . </title> . "\n";
//echo <title> . wp_get_document_title() . </title> . "\n";