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>