• Resolved sloweye

    (@sloweye)


    Hi,

    When relevanssi_kill_autoembed turns off the embeds in search results, it leaves behind the embed url. So sometimes I am seeing a long URL with a query string as a substantial percentage of search excerpts. Is there any way to filter out the Url so that the user sees a more human-friendly excerpt?

    Thank You!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter sloweye

    (@sloweye)

    Part two of this- it might also be a workable solution for me to remove the autoembed disabler. However I am unable to get this to work using the snippet you provide. Does it need a priority?

    Plugin Author Mikko Saari

    (@msaari)

    It shouldn’t, it’s the default priority. If you’re removing this in theme functions.php, you’re probably removing it before it’s added. Do it later:

    add_action( 'init', function() {
      remove_action( 'relevanssi_pre_the_content', 'relevanssi_kill_autoembed' );
    }, 99 );
    Thread Starter sloweye

    (@sloweye)

    Hello Mikko,

    Thanks for your response. I’ve tried adding the code you provided in the functions.php of my child theme, but the embed urls are still appearing in Relevanssi’s excerpts.

    As in my first post, I’d be happy to just hide the embed url in the excerpt if that is easier.

    Plugin Author Mikko Saari

    (@msaari)

    You can use the relevanssi_excerpt_content filter hook to filter out the embed URL.

    • This reply was modified 4 years, 10 months ago by Mikko Saari.
    Thread Starter sloweye

    (@sloweye)

    I was able to cobble together the following (Edited from this regex and your example for the filter), which seems to be working to remove YouTube and Vimeo urls other than for videos embedded in Woocommerce products:

    add_filter( 'relevanssi_excerpt_content', 'sly_remove_youtube_vimeo_urls' );
    function sly_remove_youtube_vimeo_urls( $content ) {
        return preg_replace( '#^(http:\/\/|https:\/\/)((player\.)?vimeo\.com|youtu\.be|www\.youtube\.com)\/([\w\/]+)([\?].*)?$#im', '', $content );
    }

    Is a different filter required to work with relevanssi’s excerpt for Woocommerce products?

    Plugin Author Mikko Saari

    (@msaari)

    If the WooCommerce products are showing a Relevanssi-generated excerpt, the same filter should apply to them, it’s the same excerpt. If they’re showing something else, then I don’t know.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Remove Url left by relevanssi_kill_autoembed’ is closed to new replies.