In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use WordPress to add Baidu query and display function to the article". In the daily operation, I believe that many people have doubts about how to use WordPress to add Baidu query and display function to the article. The editor consulted all kinds of materials and sorted out simple and useful operation methods. Hope to answer the question "how to use WordPress to add Baidu to the article whether Baidu has included query and display functions" is helpful! Next, please follow the editor to study!
The article page shows whether Baidu has included this feature in the author's blog for some time. At the beginning of the code is also found from the network, but their own use, so do not want to share, after all, is the result of others, and their own Baidu can also be found!
However, since a friend asked if I could share a tutorial on adding this feature, I decided to organize and share it.
I have always been a moderate obsessive-compulsive perfectionist, so I generally don't like to share what others have already shared! But stayed up until three o'clock last night, in addition to building a QR code API in Sina SAE, but also Baidu included query this function to achieve database storage optimization!
Function name: add query and display of whether Baidu is included or not to WordPress
Original features: query the url of this page in Baidu through curl and get the result. If it exists, the output is included, otherwise it is not included, and you can click to submit url.
Disadvantages of the original: every time you open the page, you need to query it in Baidu, which slows down the speed seriously! Of course, you can use the cache plug-in to solve this problem.
Improved features:
I, query the results of url collection in Baidu through curl, and write the results to the database if it has been included. When you open the page again, first check the corresponding fields in the database to determine whether it has been included, and if it has been included, it will be output directly, instead of executing the curl query, thus solving the problem of curl real-time query slowing down!
Ii, if the query result is included, it will also output a tag to query the title of the article in Baidu, which can be used to check the ranking of the article, and even check whether it has been reprinted or tampered with!
First of all, share how to use the data storage version I am currently using:
①, add baidu_record field to wp_posts table of WordPress database
i. To enter phpMyAdmin, first select the WordPress database, and then click SQL:
ii. Paste the following code and execute it to add a baidu_record field to wp_posts:
PS: when it comes to operating the database, you should always remember to export a backup of the database first, just in case!
If you execute an error report:
Please check if the table prefix is wp_,. If not, please change the code to the actual table name and try again.
Ii, if you still report an error, it may be that the current account does not have the permission to add fields, so find your own way to find an account with higher permissions to operate.
②, edit the functions.php file of the theme directory, add the following code before the last? > and save it:
③, edit the article template (usually single.php), add the following code in the appropriate location, and save:
For example, the author's blog added it to the subtitle.
If the above steps are not wrong, then visit the article page to see whether Baidu has included the effect. Of course, if you are interested, you can also like Zhang GE blog because, continue to add this code to the home page or classification page.
The first visit may be a bit stuck, when there are records in the database, it will be queried directly from the database without any sense of slowing down!
Of course, some friends are still worried that there will be problems with operating the database, so they finally share the real-time query version of this feature:
①, edit the functions.php of the theme directory, add the following code before the last? >, and save:
②, edit the article template file (usually single.php), add the following code in the appropriate location and save it:
If there is no problem, visit the article page can also see the same effect, of course, this is a real-time query, every time to open the page to execute a curl, if the host configuration and network are not strong, it may be more difficult! Of course, you can use caching plug-ins like wp-super-cache to solve this problem by caching pages!
The above two versions can be selected according to personal preferences and the actual situation of the host!
At this point, on the "how to use WordPress to add Baidu to the article whether Baidu has included query and display function" study is over, I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.