我必须编写一个外部程序,我看不到任何其他方式。在我的案例中,我使用了Java JDBC。
查询:
SELECT p.post_title, m.meta_value
FROM wp_term_taxonomy tt
INNER JOIN wp_term_relationships tr on tt.term_taxonomy_id = tr.term_taxonomy_id
inner join wp_posts p on p.ID = tr.object_id
inner join wp_posts p2 on p.ID = p2.post_parent
inner join wp_postmeta m on p2.ID = m.post_id
where tt.term_id = 795
and p.post_status = \'publish\'
and p.post_type = \'post\'
and p2.post_type=\'attachment\' and p2.post_status = \'inherit\'
and m.meta_key = \'_wp_attached_file\'
但无法复制到特定的mycat,wordpress无法识别媒体的自定义文件夹结构。
然后,由于所有图像都是当前年份/月份的,我做了:
UPDATE wp_posts p
SET p.post_content = REPLACE(p.post_content, \'http://miwp.local/wp-content/uploads/2014/02/\', \'http://miwp.local/wp-content/uploads/2016/04/\'),
p.post_content = REPLACE(p.post_content, \'http://miwp.local/wp-content/uploads/2014/03/\', \'http://miwp.local/wp-content/uploads/2016/04/\'),
p.post_content = REPLACE(p.post_content, \'http://miwp.local/wp-content/uploads/2014/04/\', \'http://miwp.local/wp-content/uploads/2016/04/\'),
p.post_content = REPLACE(p.post_content, \'http://miwp.local/wp-content/uploads/2014/05/\', \'http://miwp.local/wp-content/uploads/2016/04/\'),
p.post_content = REPLACE(p.post_content, \'http://miwp.local/wp-content/uploads/2014/06/\', \'http://miwp.local/wp-content/uploads/2016/04/\'),
p.post_content = REPLACE(p.post_content, \'http://miwp.local/wp-content/uploads/2014/07/\', \'http://miwp.local/wp-content/uploads/2016/04/\'),
p.post_content = REPLACE(p.post_content, \'http://miwp.local/wp-content/uploads/2014/08/\', \'http://miwp.local/wp-content/uploads/2016/04/\'),
p.post_content = REPLACE(p.post_content, \'http://miwp.local/wp-content/uploads/2014/09/\', \'http://miwp.local/wp-content/uploads/2016/04/\')
WHERE p.post_name LIKE \'mycat-%\';
提供的post\\u名称前缀为“mycat-”。