This question has already been answered:

There are about a thousand links that need to be removed from wordpress without affecting the link text. There is such a code that is suggested on another resource, but it does not work correctly. Inserted into functions.php for a single pass.

function links_remove () { $args = array ('numberposts' => 9999); $allposts = get_posts( $args ); foreach( $allposts as $post ) { $id = $post->ID; $content = $post->post_content; $links_mass=array( /* Здесь сотни абсолютно разных ссылок через запятую */ 'site.com' ); foreach($links_mass as $link) { $_ = str_replace($links_mass, '', $content); $new_content = preg_replace('~<a\s*href="">([^<]+)<\/a>~', "$1", $_); $new_post = array(); $new_post['ID'] = $id; $new_post['post_content'] = $new_content; wp_update_post( $new_post ); } } } add_action ('init', 'links_remove'); 

It finds and "deletes" links only on the page that I am downloading at the moment. Those. if this is the main one, then there it will not delete anything, or if a post that has no links from the array, then nothing will change either. And if this is a post in which there are links from an array, then the link becomes a form:

 <a href="http://">Сайт</a> 

Reported as a duplicate by Denis , aleksandr barakin , iluxa1810 , HamSter , αλεχολυτ 10 Nov '16 at 8:55 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

1 answer 1

I solved a similar problem with an “ax” - I exported the posts table, I deleted links with a regular expression in a notepad ++ with a replacement for a regular expression. However, I didn’t have any "legal" outgoing, I didn’t post links to the images, so the task was quite simple - it was necessary to simply wipe all the tags from "" and "".