简体   繁体   中英

MY SQL Query for remove all a tags from field

I have a WordPress website, which was under malware attack recently. I manage to remove all malware files and ad security.

But that hacker injected some random urls like below to end of all post contents. site have around 1.5k posts.

<a href="http://www.cgparkaoutlet.com">canada goose outlet</a>  <a href="http://www.cgparkaoutlet.com">canada goose outlet</a>

在此处输入图片说明

I need to remove this these links. already tested this mysql but it's not working

UPDATE wp_posts SET post_content = REPLACE(post_content, substring_index( substring_index(post_content, 'href="', -1),  '"', 1),'');
UPDATE wp_posts SET post_content = REPLACE(post_content, '<a href="">','');
UPDATE wp_posts SET post_content= REPLACE(post_content, '<a href="" target="_blank">','');
UPDATE wp_posts SET post_content= REPLACE(post_content, '</a>','');

anyone know how to remove those links from all posts without aging contents. Thank You

I suggest you , use wp_strip_all_tags wordpress function for example :

global $wpdb;
$wpdb->query("update `wp_posts` set post_content = ".wp_strip_all_tags( $string ) ....);

https://codex.wordpress.org/Function_Reference/wp_strip_all_tags

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM