Add keywords and descriptions on the WordPress page in non-plug-in mode

Source: Internet
Author: User
There is a problem with WordPress, that is, the lack of keywords and description information on the page. In fact, this work should be completed by the topic. Unfortunately, most of the topics are not involved, which leads to the lack of the two information.

WordPress has a problem, that is, the lack of keywords and description information on the page. In fact, this task should be completed by the topic. Unfortunately, most of the topics are not involved, therefore, the lack of these two information is very unfavorable for SEO. The following describes how to use a non-plug-in to call keywords and description in the template. Directly on the code, the following is the topic of the Tianya PHP blog [http://blog.phpha.com] code, you can modify it according to the actual situation, you can leave a message if you do not understand.

 
  1. <? Php <li> if (is_category () {<li> single_cat_title (); <li >} elseif (is_single () | is_page ()) {<li> single_post_title (); <li >}elseif (is_search () {<li> echo wp_specialchars ($ s ); <li >}else {<li> wp_title ('', true); <li >}< li> if (! Is_home () {<li> echo '-'; <li >}< li> echo 'tianya PHP blog | PHP blog'; <li >?>
  2. // Http://blog.phpha.com
  3. If (is_page ()){
  4. $ Description = mb_strimwidth (strip_tags (apply_filters ('The _ content', $ post-> post_content), 0,200 ,'...');
  5. $ Keywords = $ post-> post_title;
  6. } Elseif (is_category ()){
  7. $ Description = trim (strip_tags (category_description ($ cat_ID )));
  8. $ Keywords = single_cat_title ('', false );
  9. } Elseif (is_tag ()){
  10. $ Keywords = single_tag_title ('', false );
  11. $ Description = trim (strip_tags (tag_description ($ tag_ID )));
  12. } Elseif (is_single ()){
  13. If ($ post-> post_excerpt ){
  14. $ Description = $ post-> post_excerpt;
  15. } Else {
  16. $ Description = mb_strimwidth (strip_tags (apply_filters ('The _ content', $ post-> post_content), 0,200 ,'...');
  17. }
  18. $ Keywords = $ post-> post_title;
  19. } Else {
  20. $ Keywords = 'php blog, PHP, MySQL, Linux, C, programming algorithm, website architecture, internet ';
  21. $ Description = 'focus on WEB development and love PHP/MySQL/Linux/C/programming algorithms/website architectures, advocating free Internet access ';
  22. }
  23. ?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.