Title: SVG code appear in search results
Last modified: November 21, 2025

---

# SVG code appear in search results

 *  [korg007](https://wordpress.org/support/users/gillesgagnon/)
 * (@gillesgagnon)
 * [5 months ago](https://wordpress.org/support/topic/svg-code-appear-in-search-results/)
 * Hi Mikko, Thanks for offering this great plugin. We’re trying to use it on our
   site in development (link privately shared).
   The site uses Elementor Pro and 
   the issue we’re experiencing is that pages use the Elemenntor DIvider widget 
   with an custom SVG icon. It appears part of that svg code is included in the 
   search results. For example “.st0{fill:#424143;}” appears in search results where
   the widget is used.
 * How can we prevent this from occurring and display only the actual text of pages?
 * We look forward to hearing form you,
   Cheers!
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fsvg-code-appear-in-search-results%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [5 months ago](https://wordpress.org/support/topic/svg-code-appear-in-search-results/#post-18728048)
 * It’s because the SVG icon looks like this:
 *     ```wp-block-code
       <svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" viewBox="0 0 12 10.5">	.st0{fill:#424143;}<g> ... </g></svg></div>
       ```
   
 * When Relevanssi strips the tags, the SVG tag is removed, but the contents of 
   the tag remain – that’s the standard way to handle HTML tags, and Relevanssi 
   doesn’t know that the `<svg>` tag is special and the contents of the tag should
   also be removed.
 * This is something I will fix in the next version of Relevanssi. The `<svg>` tags
   will then be completely removed. Meanwhile, you can use this snippet on your 
   site to fix the problem:
 *     ```wp-block-code
       add_filter( 'relevanssi_excerpt_content', function( $content ) {	return preg_replace( '#<svg.*?</svg>#', '', $content );} );
       ```
   
 * This will remove all `<svg>` tags from the post content before Relevanssi generates
   the excerpts.
 *  Thread Starter [korg007](https://wordpress.org/support/users/gillesgagnon/)
 * (@gillesgagnon)
 * [5 months ago](https://wordpress.org/support/topic/svg-code-appear-in-search-results/#post-18728178)
 * Thanks a million, Mikko!
   I’ll implement the shortcode while we wait for the permanent
   fix.On that same page, why is it that the Search Bar function, at the top right,
   becomes non-responsive and can not be used following an initial search? That 
   is, after search results are displayed, the user can not perform another search
   as the Search field appears disabled.We look forward to your response.
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [5 months ago](https://wordpress.org/support/topic/svg-code-appear-in-search-results/#post-18728661)
 * I can’t reproduce that error. I can make repeated searches without problems.
 *  Thread Starter [korg007](https://wordpress.org/support/users/gillesgagnon/)
 * (@gillesgagnon)
 * [5 months ago](https://wordpress.org/support/topic/svg-code-appear-in-search-results/#post-18728672)
 * Thanks for checking Mikko. You’re correct. I tried a diff browser and all is 
   well. Maybe it’s one of my chrome extensions. My apologies.
 *  Thread Starter [korg007](https://wordpress.org/support/users/gillesgagnon/)
 * (@gillesgagnon)
 * [5 months ago](https://wordpress.org/support/topic/svg-code-appear-in-search-results/#post-18729260)
 * Hi Mikko, I wanted to report back. 
   It wasn’t an extension. It turns out the 
   issue of not being able to access the Search field arises if I’m logged in as
   Admin, and have performed a successful search (search results displayed). Under
   those conditions, for some reason Elementor (?) adds this CSS rul which breaks
   the Search:.elementor-widget-search .hidden {    opacity: 0;    visibility: hidden;}
 * ** The problem only exists if I turn on Relevanssi’s “Create custom search result
   snippets”. Which in my case, I need.
 * I had to add robust css to override it, using the .logged-in class. 
   Any thoughts?
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [5 months ago](https://wordpress.org/support/topic/svg-code-appear-in-search-results/#post-18729267)
 * This is normal weirdness from Elementor. If you can fix it, you can ignore it.
 *  Thread Starter [korg007](https://wordpress.org/support/users/gillesgagnon/)
 * (@gillesgagnon)
 * [5 months ago](https://wordpress.org/support/topic/svg-code-appear-in-search-results/#post-18729280)
 * hahaha! yes, Elem weirdness does rear its head at times.
   I hope this bit will
   prevent others from pulling their hair out.Keep up the good work Mikko.

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

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fsvg-code-appear-in-search-results%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/relevanssi/assets/icon-256x256.png?rev=2025044)
 * [Relevanssi - A Better Search](https://wordpress.org/plugins/relevanssi/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/relevanssi/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/relevanssi/)
 * [Active Topics](https://wordpress.org/support/plugin/relevanssi/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/relevanssi/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/relevanssi/reviews/)

## Tags

 * [divider](https://wordpress.org/support/topic-tag/divider/)
 * [svg](https://wordpress.org/support/topic-tag/svg/)

 * 7 replies
 * 2 participants
 * Last reply from: [korg007](https://wordpress.org/support/users/gillesgagnon/)
 * Last activity: [5 months ago](https://wordpress.org/support/topic/svg-code-appear-in-search-results/#post-18729280)
 * Status: not resolved