• Is there a way to escape the search highlighting or specify where we want it to happen?

    Currently, the HTML gets borked up by it:

    <a href="http://clri-ltc.ca/files/2016/01/emodules_pleasurable_dinning_EN.zip" class="single-resource-module-link clicked" data-type="download" data-label="<span class=" search-everything-highlight-color"="" style="background-color:orange">Pleasurable <span class="search-everything-highlight-color" style="background-color:orange">dining</span> (Module 2)">Pleasurable dining (Module 2) - ZIP</a>

    The only thing I could find on Google was someone having the same issue 4 years ago but their thread was closed.

    Thank you

    https://ww.wp.xz.cn/plugins/search-everything/

Viewing 1 replies (of 1 total)
  • Thread Starter sanch3x

    (@sanch3x)

    So the highlighting is applied to the_title, the_content, and the_exercpt filters. This means that a call to get_the_title() or the_title() will be highlighted (which makes total sense).

    In the example above, I was placing the title in a HTML attribute to track click-through rates in my analytics. The solution was to echo out the title attribute instead of using the WP functions.

    So from:

    title="<?php the_title(); ?>"

    to:

    title="<?php echo esc_attr( $post->post_title ); ?>"

    Hope that helps someone in the future.

Viewing 1 replies (of 1 total)

The topic ‘Search highlighting breaking HTML’ is closed to new replies.