WordPress.org

Ready to get started?Download WordPress

Forums

Better Search
[resolved] Style tags showing up in search results blurb (4 posts)

  1. Mattman0444
    Member
    Posted 7 months ago #

    Love the plugin so far, its FAR better than anything i've used in the past.

    My only qualm so far is that i have some <style> tags at the top of my pages that control a banner image on a per-page basis and the first line of the blurb under the search results has the stripped style code included.

    The raw html on the page would be:
    <style>some styles here</style>
    <p>Page content or whatever</p>

    The first line of the blurb is:
    some styles here Page content or whatever

    It strips the tags, but not whats in between them.

    The work around I've been doing is to move the styles to the bottom of the page, but was wondering if there is an easier way to archive this.

    https://wordpress.org/plugins/better-search/

  2. Ajay
    Member
    Plugin Author

    Posted 7 months ago #

    The best option is to actually write your own excerpt for the posts while you're writing them which ensures that the plugin displays the excerpt and not the content.

    Another option is to create your own function that filters get_bsearch_excerpt. Something along the lines of the below (untested).

    function filter_bsearch_excerpt($out) {
      $output = str_replace("some styles here","",$out);
      $output = str_replace("Page content or whateve","",$out);
    return $output
    }
    add_filter('get_bsearch_excerpt','filter_bsearch_excerpt');
  3. Mattman0444
    Member
    Posted 7 months ago #

    Perfect - and thank you for the quick reply.

    I installed a plugin that would allow me to edit excerpts on pages (not just posts) and everything works perfect.

  4. Ajay
    Member
    Plugin Author

    Posted 7 months ago #

    That's great to know! Which plugin would this be?

Reply

You must log in to post.

About this Plugin

About this Topic