How to hide oembed links from post excerpt?

Posted in: Newspaper
Post count: 3

The excerpt() function shows oembeded links and i would like to disable it.

I’ve try to insert the following functions to my functions.php

function remove_links($text)
{
if ('' == $text )
{
$pattern = '~https://[^\s]*~i'; //what we want to remove, the http link
$text = get_the_content('');
$text = preg_replace($pattern, '', $text);
}
return $text;
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'remove_links');

But it seems like doesn’t work too

Post count: 18283

Hello !

Please provide a link to your website and let us know where can we find that excerpt and link.

Thank you !

Post count: 3
Post count: 18283

Hello !

I have inspected your website and couln’t see any links in your excerpts. Can you guide us where to inspect ?

Thank you !

Viewing 4 posts - 1 through 4 (of 4 total)
The forum ‘Newspaper’ is closed to new topics and replies.