I have table name wp_posts
and in post_content
column there is a description of my posts (in HTML).
I would like to have a query that searches in post_content column and selects the tag starting with <div class
or no class>
and remove whole tag.
I dont want to remove anything inside the tag, just remove the tag
This:
<div> or <div clas="sada">
some text
</div>
Would become this:
some text
My MYSQL version is 15.1.
In your case you can write a short script which fetch all wp_posts elements. Then you iterate this collection and remove with reg. expression function the div tags and update the field again in your database.
This would be the expression which remove the div tag. $wp_content = preg_replace('/\<[\/]{0,1}div[^\>]*\>/i', '', $wp_content);
if you are using wordpress, you must have php access, so you can use strip_tags() to remove the html from the variable.
I find a solution here , write it here for others:
update wp_posts
set post_content = REGEXP_REPLACE(post_content, '</?div.*?>', '');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.