这篇文章主要为大家详细介绍了实用WordPress后台MySQL操作命令的简单示例,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随四海网的小玲来看看吧!
不过假设你的WordPress网站上有成百上千篇文章,而你需要进行全站范围的改动, 这时从后台逐条编辑就有点费时费力了,并且犯错的几率也会提高。 最好的方法是进入WordPress的MySQL数据库执行必要的查询(改动)。 通过MySQL可以迅速地完成以上任务,为你节省更多时间。代码如下:
INSERT INTO wp_postmeta (post_id, meta_key, meta_value)
SELECT ID AS post_id, 'UniversalCustomField'
AS meta_key 'MyValue AS meta_value FROM wp_postsWHERE ID NOT IN (SELECT post_id FROM wp_postmeta WHERE meta_key = 'UniversalCustomField');
代码如下:
INSERT INTO wp_postmeta (post_id, meta_key, meta_value)
SELECT ID AS post_id, 'UniversalCustomField'
AS meta_key 'MyValue AS meta_value
FROM wp_posts WHERE ID NOT IN
(SELECT post_id FROM wp_postmeta WHERE meta_key = 'UniversalCustomField')`` AND post_type = 'post';
代码如下:
INSERT INTO wp_postmeta (post_id, meta_key, meta_value)
SELECT ID AS post_id, 'UniversalCustomField'
AS meta_key 'MyValue AS meta_value
FROM wp_posts WHERE ID NOT IN
(SELECT post_id FROM wp_postmeta WHERE meta_key = 'UniversalCustomField')AND `post_type` = 'page';
代码如下:
DELETE FROM wp_postmeta WHERE meta_key = 'YourMetaKey';
代码如下:
SELECT * From wp_terms wtINNER JOIN wp_term_taxonomy wtt ON wt.term_id=wtt.term_id WHERE wtt.taxonomy='post_tag' AND wtt.count=0;
代码如下:
DELETE FROM wp_comments WHERE wp_comments.comment_approved = 'spam';
代码如下:
DELETE FROM wp_comments WHERE comment_approved = 0
代码如下:
UPDATE wp_posts SET comment_status = 'closed' WHERE post_date < '2010-01-01' AND post_status = 'publish';
代码如下:
UPDATE wp_posts SET ping_status = 'open';
代码如下:
UPDATE wp_posts SET ping_status = 'closed';
代码如下:
UPDATE wp_posts SET ping_status = 'closed' WHERE post_date < '2010-01-01' AND post_status = 'publish';
代码如下:
DELETE from wp_comments WHERE comment_author_url LIKE "%nastyspamurl%" ;
代码如下:
SELECT * FROM `wp_posts` WHERE `post_type` = 'post'AND DATEDIFF(NOW(), `post_date`) > X
代码如下:
DELETE FROM `wp_posts` WHERE `post_type` = 'post'AND DATEDIFF(NOW(), `post_date`) > X
代码如下:
UPDATE wp_post SET post_content = replace(post_content, '[tweet]', '' ) ;
代码如下:
UPDATE wp_posts SET post_type = 'page' WHERE post_type = 'post'
代码如下:
UPDATE wp_posts SET post_type = 'post' WHERE post_type = 'page'
代码如下:
SELECT ID, display_name FROM wp_users;
代码如下:
UPDATE wp_posts SET post_author=NEW_AUTHOR_ID WHERE post_author=OLD_AUTHOR_ID;
代码如下:
DELETE FROM wp_posts WHERE post_type = "revision";
代码如下:
UPDATE wp_options SET option_value = 'a:0:{}' WHERE option_name = 'active_plugins';
代码如下:
UPDATE wp_options
SET option_value = replace(option_value, 'http://www.old-site.com', 'http://blog.doucube.com')
WHERE option_name = 'home' OR option_name = 'siteurl';
代码如下:
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-site.com','http://blog.doucube.com);
代码如下:
UPDATE wp_posts SET post_content = replace(post_content, ' http://www.ancien-site.com ', ' http://blog.doucube.com ');
代码如下:
UPDATE wp_users SET user_login = 'YourNewUsername' WHERE user_login = 'Admin';
代码如下:
UPDATE `wordpress`.`wp_users` SET `user_pass` = MD5('PASSWORD')
WHERE `wp_users`.`user_login` =`admin` LIMIT 1;
代码如下:
UPDATE wp_posts SET `post_content` = REPLACE (`post_content`, 'OriginalText','ReplacedText');
代码如下:
UPDATE wp_postsSET post_content = REPLACE (post_content, 'src="http://www.myoldurl.com', 'src="http://blog.doucube.com');
本文来自:http://www.q1010.com/173/15983-0.html
注:关于实用WordPress后台MySQL操作命令的简单示例的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。