The meta tags keywords and description provided by the WordPress theme you download are generally poorly made, or not provided at all, which is not conducive to SEO. This article will guide you how to add separate Description and Keywords to the homepage, categories, pages, and article pages.
Many people are using the All in One SEO plug-in to solve this problem, but many people say that this plug-in is not good. At worst, let's implement it ourselves with code.
The editor's code for setting keywords and description is provided below. Add the following code to the WordPress theme header.php between , and finally save it as UTF-8 encoding, otherwise Chinese characters will be garbled:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
When writing blog posts in the future, you only need to add two custom columns (under the article editing page, if not, click Show Options# in the upper right corner) ##), the first custom column name is keywords, and the column value contains the keywords of this article. Then add a second custom column, the name of the custom column is description, and the subsequent column value contains the description of this log. After using a custom column once, you only need to select it in the drop-down box to write a log in the future. In this way, each article has your customized keywords and description, and you can completely abandon the All in One SEO plug-in.
The description and keywords of the home page and page are written directly using PHP code. You can change the description of the Pandan Blog above to your own. The description of the category page and tag page (tag) directly takes the description of the category or tag. This can be changed in the WordPress management background as needed, and keywords takes the name of the category or tag. If you want to manually define description and keywords for each category, you can change lines 27-28 of the code to:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
WordPress Tutorial》
The above is the detailed content of WordPress sets independent Description and Keywords. For more information, please follow other related articles on the PHP Chinese website!