admin管理员组文章数量:1023738
I exported posts from site X to Y. But in every post on site X there was image attached to it (not featured image)
<a href="http://x" rel="attachment wp-att-25425"><img src="x/wp-content/uploads/2017/07/x" alt="" width="300" height="141" class="aligncenter size-medium wp-image-25425" /></a>
Is there some way to query all posts on site Y (there are 700 of them) and delete all attachments from posts (i don't need that images)?
I exported posts from site X to Y. But in every post on site X there was image attached to it (not featured image)
<a href="http://x" rel="attachment wp-att-25425"><img src="x/wp-content/uploads/2017/07/x" alt="" width="300" height="141" class="aligncenter size-medium wp-image-25425" /></a>
Is there some way to query all posts on site Y (there are 700 of them) and delete all attachments from posts (i don't need that images)?
Share Improve this question asked Apr 10, 2019 at 13:32 g3arg3ar 331 silver badge4 bronze badges 3- In what way are those attachments added to posts? Is it in the content, or as a featured image/gallery images? – djboris Commented Apr 10, 2019 at 13:40
- If you're not able to edit the files as mentioned by @leymannx in the answer below, you can also use the the WP-CLI search-replace function in combination with a regex to erase the images from site Y's database. If using a regex you need to make sure, the markup is always the same, as you may get unexpected results otherwise. – Fabian Marz Commented Apr 10, 2019 at 14:47
- those attachments are in content – g3ar Commented Apr 10, 2019 at 20:08
1 Answer
Reset to default 0Having that resulting XML file from the export it's just a matter of editing it precisely to get rid of the images before importing it on the other site.
Taking Sublime Text for example it's pretty easy to find and select all occurrences of [caption
and add a line break before them for example. Same for the closing tag. Then find and select all occurrences of [caption
again and in the menu under "Selection" select "Expand selection to line". Then hit delete on your keyboard, done.
Maybe you need to separate all occurrences of <![CDATA[[caption
(featured images if I'm right) first by replacing them with some custom token to have them excluded by the in-post image search.
I exported posts from site X to Y. But in every post on site X there was image attached to it (not featured image)
<a href="http://x" rel="attachment wp-att-25425"><img src="x/wp-content/uploads/2017/07/x" alt="" width="300" height="141" class="aligncenter size-medium wp-image-25425" /></a>
Is there some way to query all posts on site Y (there are 700 of them) and delete all attachments from posts (i don't need that images)?
I exported posts from site X to Y. But in every post on site X there was image attached to it (not featured image)
<a href="http://x" rel="attachment wp-att-25425"><img src="x/wp-content/uploads/2017/07/x" alt="" width="300" height="141" class="aligncenter size-medium wp-image-25425" /></a>
Is there some way to query all posts on site Y (there are 700 of them) and delete all attachments from posts (i don't need that images)?
Share Improve this question asked Apr 10, 2019 at 13:32 g3arg3ar 331 silver badge4 bronze badges 3- In what way are those attachments added to posts? Is it in the content, or as a featured image/gallery images? – djboris Commented Apr 10, 2019 at 13:40
- If you're not able to edit the files as mentioned by @leymannx in the answer below, you can also use the the WP-CLI search-replace function in combination with a regex to erase the images from site Y's database. If using a regex you need to make sure, the markup is always the same, as you may get unexpected results otherwise. – Fabian Marz Commented Apr 10, 2019 at 14:47
- those attachments are in content – g3ar Commented Apr 10, 2019 at 20:08
1 Answer
Reset to default 0Having that resulting XML file from the export it's just a matter of editing it precisely to get rid of the images before importing it on the other site.
Taking Sublime Text for example it's pretty easy to find and select all occurrences of [caption
and add a line break before them for example. Same for the closing tag. Then find and select all occurrences of [caption
again and in the menu under "Selection" select "Expand selection to line". Then hit delete on your keyboard, done.
Maybe you need to separate all occurrences of <![CDATA[[caption
(featured images if I'm right) first by replacing them with some custom token to have them excluded by the in-post image search.
本文标签: Delete attached images from posts
版权声明:本文标题:Delete attached images from posts 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745605217a2158693.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论