This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

html showing up in search results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support html showing up in search results

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #25447
    seankells38seankells38
    Participant

    Hi,

    I am using Ajax search pro and have it set to show results in a drop-down within the page.

    Unfortunately, when I do a search, the results that come back are showing some of the html coding from the pages. (Please see attached image).

    I haven’t been able to find any reason for this and am wondering if you have any ideas.

    Thanks

    Sean

    #25466
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi Sean,

    Thank you for all the details, it helped a lot.

    Okay, this was a tough one. I found that all pages were made with some sort of a custom page builder. Interestingly, the page content in the database contains some internal modules from the page builder itself – including encoded (html entity encoded) HTML as text, buttons etc.. I am not sure why they are doing that.
    The escaped HTML is basically considered as simple text, and even though the plugin does html removal and other stuff, this is not recognized as HTML, since it is escaped. To bypass this issue to some extent, I had to put this code to the functions.php file in your theme directory:

    add_filter('asp_results', 'asp_filter_invalid_html', 10, 1);
    function asp_filter_invalid_html( $results ) {
    	foreach ( $results as $k => &$r ) {
    		$r->content = strip_tags(html_entity_decode($r->content));
    	}           
    	return $results;
    }

    This may help a bit, but it is definitely not perfect. The encoded HTML should not be there in the first place, this code will force decoding of the HTML entities, and escape them again.

    #25486
    seankells38seankells38
    Participant

    Thanks Ernest! Great support, really appreciate it.

    Sean

    #25498
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘html showing up in search results’ is closed to new replies.