You can use SQL statements to modify Wordpress blog content in batches. All statements in the article use the default WP _ table prefix. If your data table prefix is not WP _, you need to change it in the statement.
-
Modify document content in batches
If you want to replace some of the content in all the previous articles, such as changing the blog name, changing the blog URL, and changing the link of the article layout, you can use the following SQL statement:
Update wp_postsset post_content = Replace (post_content, 'old blog name', 'new blog name ');
This statement replaces all "old blog names" in all articles with "new blog names". You can make some changes as needed. Because the content of this article is stored as HTML code in the database, the preceding SQL statement can also replace the HTML code.
If you only want to change the link of the article illustration without affecting other links, you can use the following SQL statement to replace all src = "oldurl.com with src =" newurl.com:
Update wp_postsset post_content = Replace (post_content, 'src = "oldurl.com ', 'src =" newurl.com ');
If you upload an image attachment, you need to change the guid of the Image Attachment and use the following SQL statement:
Update wp_postsset guid = Replace (guid, 'oldsiteurl. com', newsiteurl.com ') Where post_type = 'attachment ';
-
Batch modify document summary
The summary is the content entered in the "summary" box when you edit the article in the WordPress background. To change the summary in batches, use the following statement:
Update wp_postsset post_excerpt = Replace (post_excerpt, 'baidu', 'Baidu ');
This statement replaces all the words "Baidu" in the abstract with "Baidu ".
-
Batch modify the author of an article
Suppose your blog has two registered users, Zhang Sanhe and Li Si. What should you do at this time? You can execute the following statement:
Update wp_postsset post_author = Li Si user idwhere post_author = Zhang San user ID;
So how do I obtain the user IDs of Li Si and Zhang San? You can run the following SQL statement:
Select ID, user_nicename, display_name from wp_users;
The IDS, nicknames, and publicly displayed names of all registered users on your blog are listed. Assume that the ID of John is 2 and that of John is 5. Then, you can write the SQL statement as follows:
Update wp_postsset post_author = 5 where post_author = 2;
-
Modify the URL of comments in batches
Assume that your blog has a very loyal reader who leaves many useful comments for your blog articles. At the same time, his comments are filled with the URL of the message holder's website, but one day his blog domain name changed and asked you to update the website URL in his message. What do you do? It is not practical to manually change it one by one. You can use the following SQL statement:
Update wp_commentsset comment_author_url = Replace (comment_author_url, 'oldurl. com', 'newurl. com ')
The preceding statement changes the old website link oldurl.com of the message contact to newurl.com.
-
Disable pingback for all articles
Enable the pingback function to send you a notification when someone else references your article link. However, this function does not seem very helpful to our article, so why not disable pingback? In the WordPress background-settings-discussion, uncheck "receive reference notifications from external blogs (pingbacks and trackbacks)". In this way, pingback will not be enabled for any subsequent articles, however, this option does not work for the previous published articles. You still need to use SQL:
Update wp_postsset ping_status = 'closed ';
-
Delete revision of all articles
Under normal circumstances, the revision of an article does not make much sense for most people, and the number of revisions will increase as you modify the document, which will increase the database query speed, this is not a good thing. There are many articles on the Internet that teach you how to prohibit revisions, and there are many plug-ins that can delete revisions. You can search for them by yourself. Here we will show you how to use SQL statements to delete all generated document revision data:
Delete A, B, cfrom wp_posts Aleft join wp_term_relationships B on (. id = B. object_id) left join wp_postmeta C on (. id = C. post_id) where. post_type = 'revision ';
-
Deletes all comments from a reviewer.
If your blog wants to block a person and delete all his or her messages on your blog, you can use the following SQL statement.
(1) Delete A comment based on the blog URL of the message recipient. The following SQL statement will delete all comments whose URLs are www.example.com:
Delete from wp_commentswhere comment_author_url like '% www.example.com % ';
(2) Delete A comment based on the nickname of the message owner. The following statement deletes all comments whose nicknames are example:
Delete from wp_commentswhere comment_author = 'example ';
(3) Delete a message by email. The following statement deletes all [email protected] comments:
Delete from wp_commentswhere comment_author_email = '[email protected]';
-
Replace sensitive words in all comments
Internet monitoring in China shows a constantly increasing trend. If a large number of sensitive words appear in your blog comments, it may not be far from being attacked. The best practice is to replace sensitive words to ensure the security of your blog. In the following SQL statement, replace "fuck" with "**" in all comments and change the content as needed.
Update wp_commentsset comment_content = Replace (comment_content, 'fuck ','**');
-
Disable post comment
Sometimes your blog may need to close the comment for some reason. In the WordPress background-settings-discussion, uncheck "allow people to post comments for new articles". By default, comments will be disabled for subsequent posts. However, if you want to close a comment in a previous article, you need to modify the comment settings one by one. This is a pain point. The following SQL statements help you easily close comments in batches.
(1) Close comments of all old articles: Normally, few people comment on an old article. Generally, most of the visitors who visit the old article come from the search engine. This is a good thing, however, some new questions, especially technical questions, may be raised by visitors. However, you may have forgotten the technical details mentioned in this article, which will make it difficult for you to do so. The best practice is to disable comments from old articles. The following SQL statement will disable comments from all previous articles published on. you can modify the date as needed:
Update wp_postsset comment_status = 'closed 'Where post_date <'2017-01-01' and post_status = 'Publish ';
(2) Close comments of all articles: unfortunately, you have to close comments of all articles under the threat of force majeure. You can use the following SQL statement:
Update wp_postsset comment_status = 'closed 'Where post_status = 'Publish ';