In the previous tutorial, we created the header. keywords and description information are not added to the PHP file. although some people say that Baidu does not pay attention to keywords and description information, it is always better than Baidu. Therefore, we need to add keywords and descriptions.
In the previous tutorial, we created the header. keywords and description information are not added to the PHP file. although some people say that Baidu does not pay attention to keywords and description information, it is always better than Baidu. Therefore, we need to add keywords and descriptions. Of course, we have added the wp_head function in the header, so we can use the seo plug-in to output keywords and descriptions.
Open the header. php file under the content \ themes \ Aurelius folderBetween (if not, loadFront)
ID, "description", true); $ description2 = mb_strimwidth (strip_tags (apply_filters ('The _ content', $ post-> post_content), 0,200 ,"... "); // When entering the custom field description, the content of the custom field is displayed. Otherwise, use the first 200 words in the document as the description $ description = $ description1? $ Description1: $ description2; // when entering the custom field keywords, the content of the custom field is displayed. Otherwise, the tags keyword $ keywords = get_post_meta ($ post-> ID, "keywords", true); if ($ keywords = '') {$ tags = wp_get_post_tags ($ post-> ID); foreach ($ tags as $ tag) {$ keywords = $ keywords. $ tag-> name. "," ;}$ keywords = rtrim ($ keywords, ',') ;}} elseif (is_category () {$ description = category_description (); $ keywords = single_cat_title ('', False);} elseif (is_tag () {$ description = tag_description (); $ keywords = single_tag_title ('', false );} $ description = trim (strip_tags ($ description); $ keywords = trim (strip_tags ($ keywords);?>
In this way, when we add or edit an article. You only need to add a custom field. the first custom field name is keywords, and the field value is the keyword of this article. Then add the second custom field, which is called description. :
Description and keywords of home and page are directly written in PHP code. you can change the description of the above blog to yours.
The category page and the description of the tab are directly described as the category or tag. this can be changed in the WordPress management background as needed, and the keywords are named as the category or tag name.
Okay, so we can get rid of the plug-in. you can manually add keywords and description information for the article, but it is not very convenient to input or select each time. In future tutorials, we will discuss how to add a fixed panel. Effect