Optimize the HotNews Pro theme SEO code

HotNews Topic seventy-two 11K Reading mode
abstract The HotNews Pro theme itself has integrated SEO optimization code, so it is not necessary to install plug-ins similar to All in One SEO Pack. However, the SEO code of the theme integration does not provide a description (

The HotNews Pro theme itself has integrated the SEO optimization code, so there is no need to install plug-ins similar to the All in One SEO Pack. However, the SEO code of the theme integration does not provide description and keywords for the classified list and page files. Some children's shoes asked how to add this function, so they simply modified the SEO code to add this function, I just don't know what the practical significance is. The specific method is simple:

Open the seo.php template file in the HotNews Pro theme includes directory, and replace all of them with the following code.

  1. <? php  if  ( is_home() ) { ?><title><?php bloginfo('name');  ?>  | <? php bloginfo('description');  ?></ title><?php } ?>
  2. <? php  if (is_search()) {?><title>Search Results |<? Php bloginfo ('name ');  ?></ title><?php } ?>
  3. <? php  if  ( is_single() ) { ?><title><?php  echo  trim(wp_title( '' ,0));  ?>  | <? php bloginfo('name');  ?></ title><?php } ?>
  4. <? php  if  ( is_page() ) { ?><title><?php  echo  trim(wp_title( '' ,0));  ?>  | <? php bloginfo('name');  ?></ title><?php } ?>
  5. <? php  if  ( is_category() ) { ?><title><?php single_cat_title();  ?>  | <? php bloginfo('name');  ?></ title><?php } ?>
  6. <? php  if  ( is_month() ) { ?><title><?php the_time('F');  ?>  | <? php bloginfo('name');  ?></ title><?php } ?>
  7. <? php  if  (function_exists('is_tag')) {  if  ( is_tag() ) { ?><title><?php  single_tag_title( "" , true);  ?>  | <? php bloginfo('name');  ?></ title><?php } ?>  <? php } ?>
  8. <? php  if  ( is_author() ) {?><title><?php wp_title( '' );?> All published articles |<? php bloginfo('name');  ?></ title><?php }?>
  9. <? php
  10. if  (!function_exists('utf8Substr')) {
  11.   function  utf8Substr( $str $from $len )
  12.  {
  13.       return  preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'. $from .'}'.
  14.           '((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'. $len .'}).*#s',
  15.           ' $1 ', $str );
  16.  }
  17. }
  18. if  ( is_single() ){
  19.      if  ( $post ->post_excerpt) {
  20.          $description   =  $post ->post_excerpt;
  21.     }  else  {
  22.     if (preg_match('/<p>(.*)<\/p>/iU',trim( strip_tags ( $post ->post_content, "<p>" )), $result )){
  23.      $post_content  =  $result ['1'];
  24.    }  else  {
  25.      $post_content_r  =  explode ( "\n" ,trim( strip_tags ( $post ->post_content)));
  26.      $post_content  =  $post_content_r ['0'];
  27.    }
  28.           $description  = utf8Substr( $post_content ,0,220);
  29.   }
  30.      $keywords  =  "" ;
  31.      $tags  = wp_get_post_tags( $post ->ID);
  32.      foreach  ( $tags   as   $tag  ) {
  33.          $keywords  =  $keywords  .   $tag ->name .   "," ;
  34.     }
  35. }
  36. ?>
  37. <? php  echo   "\n" ;  ?>
  38. <? php  if  ( is_single() ) { ?>
  39. <meta name= "description"  content= "<?php echo trim($description);  ?> "  />
  40. <meta name= "keywords"  content= "<?php echo rtrim($keywords,',');  ?> "  />
  41. <? php } ?>
  42. <? php  if  ( is_page() ) { ?>
  43. <meta name= "description"  content= "<?php $description = get_post_meta($post->ID, 'description', true); {echo $description;}?> "  />
  44. <meta name= "keywords"  content= "<?php $keywords = get_post_meta($post->ID, 'keywords', true); {echo $keywords;}?> "  />
  45. <? php } ?>
  46. <? php  if  ( is_category() ) { ?>
  47. <meta name= "description"  content= "<?php echo category_description( $categoryID );  ?> "  />
  48. <? php } ?>
  49. <? php  if  ( is_tag() ) { ?>
  50. <meta name= "description"  content= "<?php echo single_tag_title();  ?> "  />
  51. <? php } ?>
  52. <? php  if  ( is_home() ) { ?>
  53. <meta name= "description"  content= "<?php echo get_option('swt_description');  ?> "  />
  54. <meta name= "keywords"  content= "<?php echo get_option('swt_keywords');  ?> "  />
  55. <? php } ?>

Including:

Category list page, Directly call the category description as the page description of the category, without keywords.

Tab page, Directly call the tag name as description

Page file, To add custom columns for this page:

Name: description, value: description of the page

Name: keywords, value: keyword of the page

It could have automatically intercepted part of the page file to describe the page, but the original SEO code extracted the tag as a keyword. It seems that WP does not provide the tag adding function for the page file, so it is directly implemented by using a custom column.

The specific effect can be viewed through My Recent Message Page source file

Tip: After copying the above code, you need to manually delete the extra spaces, otherwise there will be a large area of empty segments in the source code of the page, or you can directly download the modified seo.php template file to replace the original theme file.

Supplement to the article "Optimize the HotNews Pro Theme SEO Code"

HotNews Pro version 2.7 has been released for some time, and after that, I wrote some articles about modification and optimization intermittently. It is also the time to upgrade the theme. I hope you can put forward reasonable suggestions for optimization to make the upgraded theme more perfect.

Most of the articles on this site are original and used for personal learning records, which may be helpful to you, for reference only!

 weinxin
My Wechat
Copyright Notice
Please indicate the source and link of the original article reprinted on this site. Thank you for your cooperation!
five hundred and ninety-eight million eight hundred and forty-five thousand and six
 
 Robin
five hundred and ninety-eight million eight hundred and forty-five thousand and six
Comments seventy-two    Visitors fifty-eight    Author eleven
    •  Louis Vuitton
      Louis Vuitton four

      Grab a dragon chair and sit down! Interesting!

      •  Louis Vuitton
        Louis Vuitton four

        Thanks for sharing!

        •  Market forecast
          Market forecast one

          The first three are worth learning..

          •  Science bus
            Science bus six

            Support Brother Bird! Thank you!

            •  Shijiazhuang Wedding Photography
              Shijiazhuang Wedding Photography four

              Brother Bird has optimized again. It's good

              •  A wall
                A wall four

                Not bad, really optimized

                •  Vital bead
                  Vital bead three

                  Although I don't want to change it, I still support it.

                  •  AI
                    AI zero

                    Hello blogger, a small problem. If I put html code in the summary, part of the content will be displayed on the page when it is used as a description. How can I solve this problem?

                    •  neverno
                      neverno two

                      Add so many judgments, I wonder if it will further slow down the whole blog?

                        •  Robin
                          Robin

                          @ neverno In my opinion, fast and slow are only related to the host space you use
                          Everything else is bullshit

                        •  Novice learning
                          Novice learning one

                          Ask me a question, but I haven't understood it for a long time. It's about gadgets.
                          What can I do if I don't want the articles under a certain ID to be displayed in the "Latest Articles"?

                          Ps: Inspired by the "excluded classification ID", please give me some advice~(^ o ^)

                            •  Robin
                              Robin

                              @ Novice learning Add a&cat=- 123 parameter

                                •  Novice learning
                                  Novice learning one

                                  @ Robin Thank you for your reply. I am quite simple. I answered the email directly.&cat=where should I put it

                              •  Win7en Paradise
                                Win7en Paradise eight

                                Thank you, Brother Bird! This optimization is very good!

                                •  3d Forest Dance Latest Trojans
                                  3d Forest Dance Latest Trojans one

                                  Support when passing

                                  •  Game Daniel
                                    Game Daniel one

                                    Brother Bird, how to get rid of Tencent Weibo and Sina Weibo under the website? I don't want this function

                                    •  Science bus
                                      Science bus six

                                      For the upgrade theme of Brother Bird, consider that the preview image of the article can be automatically displayed in the middle of the screenshot. Otherwise, if the whole picture is forced to be displayed, the picture will be deformed into neither fish nor fowl, and it is not beautiful... Also, the preview article on the home page of the article can be added with "Share to Weibo, Tencent Weibo" similar to engadget... [img] http://i1117.photobucket.com/albums/k588/john139069/1005185791-2.jpg [/img]

                                        •  Robin
                                          Robin

                                          @ Science bus Using the feature image function is to capture the middle

                                            •  Science bus
                                              Science bus six

                                              @ Robin Add "Share to Weibo, Tencent Weibo" and so on similar to engadget... Is it difficult to achieve?

                                                •  All are floating clouds
                                                  All are floating clouds one

                                                  @ Science bus It's not troublesome to add this, you can add it yourself. The position you mentioned is on the right side of the tag. Just add it at the end? Then define the css style. Or replace the tag directly

                                            •  Sioux idea
                                              Sioux idea four

                                              Problem response picture effects and albums do not support the external chain of QQ space pictures

                                                •  Robin
                                                  Robin

                                                  @ Sioux idea Maybe there are too many restrictions on QQ album, ignoring

                                                •  Hello Beautiful
                                                  Hello Beautiful four

                                                  After trying, the description and keywords of the page file are normal. However, the description of the classified directory can be seen in the source code, but cannot be detected with the website master META information detection tool. It would be perfect if the description and keywords of the classified directory name could also be added.

                                                    •  Robin
                                                      Robin

                                                      @ Hello Beautiful resolvent:
                                                      http://zmingcx.com/what-hotnews-pro-theme-seo-optimized-code-the-supplement.html

                                                    •  CAD
                                                      CAD zero

                                                      Very powerful, the theme is too beautiful, but I think the background is very heavy!

                                                      •  stayreal
                                                        stayreal zero

                                                        Can Brother Bird turn off the set cookie? Is there a solution to the problem that the CDN I use cannot be cached because of the set cookie? thank you very much indeed

                                                        •  Wind fan
                                                          Wind fan three

                                                          ha-ha. Then change it. It seems that you can't do without hard work. Brother Bird is too diligent.

                                                          •  All are floating clouds
                                                            All are floating clouds one

                                                            As soon as Brother Bird upgraded the theme, I began to repeat my work again... I had to revise all the previous modifications --

                                                            However, without challenge, there would be no trouble. What I like is the free after-sales upgrade of Brother Bird

                                                            •  Seo optimization
                                                              Seo optimization zero

                                                              The template is missing the meta tags of keywords and description

                                                              •  Bob
                                                                Bob five

                                                                It's already perfect. It needs to be upgraded, sweat!

                                                                •  Qinling Canyon Rafting
                                                                  Qinling Canyon Rafting zero

                                                                  Brother Bird. I don't know what the problem is. Now my station page cannot be used, seek guidance..

                                                                  •  dgjiaqi
                                                                    dgjiaqi two

                                                                    This is really good. It finally solves the description and keywords of the page file

                                                                    •  Five dimensional space
                                                                      Five dimensional space four

                                                                      Just replace the original file and everything is OK?? Do not use any other settings??

                                                                      •  Love Download
                                                                        Love Download two

                                                                        I don't know when to update the theme. I'm looking forward to it...

                                                                        •  kejian
                                                                          kejian one

                                                                          Replaced and added a custom column, but the description and keywords of the page source file are null

                                                                            •  kejian
                                                                              kejian one

                                                                              @ kejian Check the source file
                                                                              name=”description” content=””
                                                                              name=”keywords” content=””

                                                                                •  kejian
                                                                                  kejian one

                                                                                  @ kejian I understand that this is only for those independent pages. Other articles and albums can be labeled and described.
                                                                                  Very powerful

                                                                              •  yumanutong
                                                                                yumanutong six

                                                                                View external references. How does this function work? Does this theme have this function by default? What needs to be changed? I've been diving in your place all day today, hehe

                                                                                •  Bird's fans
                                                                                  Bird's fans one

                                                                                  Brother Bird asked me how to remove the automatically generated descriptions and keywords in addition to the description keywords set by the All in One SEO Pack when I added the All in One SEO Pack plug-in to view the source files?

                                                                                    •  Robin
                                                                                      Robin

                                                                                      @ Bird's fans HotNews Pro theme integration SEO function, no plug-in required

                                                                                    •  Flute lovers
                                                                                      Flute lovers zero

                                                                                      Hello, thank you for your spirit of sharing, but when I used your topic, I found that there were two titles in the source code of the home page. How can I modify them

                                                                                      •  Bird's fans
                                                                                        Bird's fans one

                                                                                        Brother Bird played with his friends. Nobody is here

                                                                                        •  Yuan Yuan's Blog
                                                                                          Yuan Yuan's Blog one

                                                                                          Are you going to upgrade again? Excellent! Since the HotNews Pro theme has been used, I don't want to use other themes anymore.

                                                                                          •  yangq
                                                                                            yangq three

                                                                                            Brother Bird, how to realize the file download function, that is, click Download, and the local download window will pop up immediately, and then you can download

                                                                                            •  Wordpress Theme
                                                                                              Wordpress Theme zero

                                                                                              You have written this code in great detail and collected it

                                                                                              •  Ha ha ha
                                                                                                Ha ha ha four

                                                                                                Support upgrade!

                                                                                                No one. I have seen the best theme this year. Thank you for using nano theme for free!

                                                                                                •  hurricane
                                                                                                  hurricane two

                                                                                                  Brother Bird uses url to optimize detection - Baidu's

                                                                                                  There is always a prompt [Image Alt information detection:
                                                                                                  The image alt information is incomplete. It is recommended to add alt information to the img tag of the web page (adding this information can make the pictures on the web page easier for users to retrieve)]

                                                                                                  The pictures in the article have been added with alt information, but it still doesn't work. How can I optimize them

                                                                                                  •  Adazi Information Network
                                                                                                    Adazi Information Network three

                                                                                                    Weak support~~~

                                                                                                    •  Small Z
                                                                                                      Small Z three

                                                                                                      Brother Bird, ask how to remove the keywords tag on the home page? Only go to the home page and the article page..

                                                                                                        •  Robin
                                                                                                          Robin

                                                                                                          @ Small Z Remove the code from the last but one line of the above code

                                                                                                            •  Small Z
                                                                                                              Small Z three

                                                                                                              @ Robin Yes, thank you for your help.. Another question: How did you get the three most recent articles on your home page (that is, the three articles with the new tag)? Is it the top or something changed? Our is the latest one displayed by default..

                                                                                                                •  Robin
                                                                                                                  Robin

                                                                                                                  @ Small Z The theme setting is changed, and the latest one is displayed by default

                                                                                                            •  Mick 23
                                                                                                              Mick 23 two

                                                                                                              I'm a newbie. I'm not sure I dare to change it!

                                                                                                              •  In a hurry
                                                                                                                In a hurry one

                                                                                                                Adding media and tags in writing a new article is not available, and the display options in the upper right corner do not respond. The customization, summary, alias, etc. at the bottom of the writing article content box are not too urgent!!

                                                                                                                •  In a hurry
                                                                                                                  In a hurry one

                                                                                                                  The version I downloaded "Optimize the HotNews Pro Theme SEO Code" has all the versions mentioned in it! However, adding media and tags in writing new articles is not available, and the display options in the upper right corner do not respond. Problems such as customization, summary and alias at the bottom of the content box of writing articles have not been solved. Please ask Brother Bird for help!

                                                                                                                  •  eternity2020
                                                                                                                    eternity2020 one

                                                                                                                    Brother Bird, the keywords and descriptions on the home page after your modification are as follows. How can I add keywords and descriptions by myself? I can't find where to add it!!

                                                                                                                    Description "content=" Enter your website description, which generally does not exceed 200 characters "
                                                                                                                    Keywords "content=" Enter your website keywords, which generally do not exceed 100 characters "

                                                                                                                    •  Create a month
                                                                                                                      Create a month one

                                                                                                                      I'm a novice. I don't know whether the seo with the theme can set its own keywords and descriptions like the All in One SEO Pack. If you can, can you teach me about it

                                                                                                                     anonymous

                                                                                                                    Comment

                                                                                                                    Anonymous netizens
                                                                                                                     :?:  :razz:  :sad:  :evil:  :!:  :smile:  :oops:  :grin:  :eek:  :shock:  :???:  :cool:  :lol:  :mad:  :twisted:  :roll:  :wink:  :idea:  :arrow:  :neutral:  :cry:  :mrgreen:

                                                                                                                    Drag the slider to complete validation