• Resolved peersy

    (@peersy)


    I’m using spans in my product titles and they’re showing up in the instantsearch as well as the search page when using my site. I’ve found the code that shows it but to the life of me can’t work out how to strip html from it.

    within autocomplete.php;

    <span class="suggestion-post-title"><code>data._highlightResult.post_title.value</code></span>

    & instantsearch.php;

    <div class="ais-hits--content">
    				<h2 itemprop="name headline"><a href="{{ data.permalink }}" title="{{ data.post_title }}" class="ais-hits--title-link" itemprop="url"><code>data._highlightResult.post_title.value</code></a></h2>

    is there something I’m missing as can’t see many people having this issue,

    Many thanks for any help you can give me,

    Cheers,
    Richie

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Hi Richie,

    Best solution I can think of would be to get the tags stripped out before they’re sent to Algolia, while still leaving them in the titles themselves for your own purposes.

    Something like this below should help out with that, and I have done some limited testing with it.

    function wds_algolia_strip_html_titles( $attributes, $post ) {
    	$attributes['post_title'] = strip_tags( $attributes['post_title'] );
    	return $attributes;
    }
    add_filter( 'algolia_searchable_post_shared_attributes', 'wds_algolia_strip_html_titles', 10, 2 );
    add_filter( 'algolia_post_shared_attributes', 'wds_algolia_strip_html_titles', 10, 2 );
    
    Thread Starter peersy

    (@peersy)

    You are a legend, that worked perfectly. thanks for getting back to me so quickly

    Cheers,
    Richie

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘html in post title is showing issue’ is closed to new replies.