I need to replace an html code in multiple posts. This is the code I am using:
UPDATE wp_posts SET post_content = REPLACE(post_content, 'target="_top" class="text"') WHERE 'post_content' = 'class="text"'
But I am getting an error:
#1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
near ‘) WHERE ‘post_content’ = ‘class=”text”” at line 1
Is there any solution to make it work properly ?
You need three arguments for replace, and you will also need to use
LIKEin yourWHEREclause or you won’t get any matches. Finally you don’t want single quotes aroundpost_contentin theWHEREclause. Either use backticks or nothing.