1

I recently imported quite a few posts (many thousands) into WordPress and found out that quite a few of them had images at the start of the post that were commented out <!--<img src="" />-->.

Unfortunately WordPress for whatever reason is adding this comment to all the content, so the content is there but doesn't show up. So I figured the easy way to solve this was to run a find and replace SQL statement, to find all instances and replace with nothing.

I haven't been able to figure out how to get it to work. I'm no expert with SQL, so I was figuring I could use a wildcard in the find statement but apparently not, or at least I can't figure it out.

So what I want to do is find all occurrences of commented out images and replace them with nothing, basically just delete them. The images aren't all the same. Some just have a src, some also have height and width, some have alt attributes, etc. And they are not all in the same order. So I was hoping something like UPDATE wp_posts set post_content = replace(post_content, '<!--<img %>-->', '') would work, but it doesn't.

So if anyone has any ideas on how to do this, I'd be grateful for the help.

Darin
  • 147
  • 2
  • 3
  • 11

1 Answers1

1

Have you had a look at this question. I think your problem is using the '%' without a LIKE does not work. The question recommends using a user defined function

Community
  • 1
  • 1
Jonathan
  • 585
  • 7
  • 27