Anyone who has built a website using the open-source program wordpress may be clear that the default title format of wordpress is: site name, which is not only not beautiful, but also not conducive to search engine optimization
Anyone who has built a website using the open-source program wordpress may be clear that the default title format of wordpress is: site name, which is not only not beautiful, but also not conducive to search engine optimization. For the sake of appearance and SEO optimization, we generally need to change the title to a format like "article title-site name" or "article title | site name, so how can we modify it? Listen to the bloggers for you!
First, find the header file head. php in the background and find the following code:<? Php bloginfo ('name'); wp_title ();?>
If you put the wp_title () function before the bloginfo function, you can solve the following problem: you will find that the connector "" is not connected to the title of the article and the title of the site, but is at the beginning, which has a great impact on the appearance. The cause of this problem is wp_title () the parameter settings of the function are incorrect.
Second, set the wp_title () parameter. the default usage format of this function is as follows: , $ Sep indicates the separator, which is a string; $ echo indicates whether to display, the value is true or false; the last parameter indicates the position where the separator is displayed, whether it is on the left or right, only right, it is displayed on the right, and the rest are judged to be on the left. After learning about this function, I changed the title code above to:, and the title of the article page instantly became familiar to us: "article title-site name" format, however, careful kids shoes will find that there is an extra space before and after the separator "_", which is still not perfect. how can I remove the spaces in the wordpress title?
Finally, to remove the space, you must find the position of the wp_title () function, by searching wp_title in the background source file, find the wp_title of the 528 row of the general-template.php under the wp-Des folder, the code with spaces is the "$ sep" of lines 597th, lines 603, and lines 606. there is a space before and after the code, so the two spaces are added to the generated title. It is easy to delete spaces. you only need to change "$ sep" from the three places to "$ sep.
After completing the above three steps, the title display is more in line with the SEO standards, but also looks more beautiful. The title format used by the blogger is: Homepage (website title-website subtitle) and other pages (page title | website title). the specific code is as follows: 1) echo '-page', $ paged;?>