Exclude Code from Search Results
-
I have a problem with the search results. They are displayed with code snippets in the results. They look like this:
Trainingsmethoden So individuell wie Ihr Bedarf [tm_spacer size=“lg:40″][tm_grid align=“center“ columns=“xs:1;sm:2;md:4;lg:4″ column_gutter=“md:25;lg:50″ row_gutter=“xs:20;lg:20″ lg_spacing=“padding_right:80;padding_left:80″ md_spacing=“padding_right:25;padding_left:25″][tm_box_icon align=“center“ el_class=“trainingsmethoden“ icon_color=“custom“ …
I want the search results only to show the text of the page and not the code. How can I fix this?
I am using WPBakery Page Builder.
Thank you.
-
Looks like WPBakery is using shortcodes Relevanssi doesn’t know how to handle automatically.
Does adding this to your theme
functions.phphelp?add_filter( 'relevanssi_page_builder_shortcodes', function( $shortcodes ) { $shortcodes[] = '/\[\/?tm_.*?\]/im'; } );Thank you for your quick support.
If I add the code to my functions.php I only get three dots as a preview. My search results look like this now:
Trainingsmethoden
…Sorry, the code should be:
add_filter( 'relevanssi_page_builder_shortcodes', function( $shortcodes ) { $shortcodes[] = '/\[\/?tm_.*?\]/im'; return $shortcodes; } );Thank you so much. For the most of the pages it works fine now. Except for the landing page. There the search results look like this:
Startseite
…image=“2359″ box_link=“url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fprofessionell-verkaufen-1%2F|title:Zum%20Kurs“ button=“url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fprofessionell-verkaufen-1%2F|title:Zum%20Kurs“ text=“Vertrieb Psychologische Grundlagen des menschlichen Verhaltens gezielt im Verkaufsprozess einsetzen“][tm_box_large_image style=“03″ xs_align=“center“ heading=“Professionell verkaufen …Every time I search for a term that is set up in a special box element, the results look like this.
Do you have any idea?My initial thought here is: should the front page be in the index in the first place? At least the box element shouldn’t, as it’s just referencing other posts.
Anyway, I’m not sure why the code isn’t working there. Those boxes look like they’re using similar shortcodes.
What’s the shortcode for the slider? It would probably best to just make Relevanssi remove the whole slider.
I made a few more tests. Every time this slider element shows up and I search for a word that is in this slider element, the text gets displayed with the shortcodes.
The shortcode for this slider element is: [tm_slider_group]
Try this code:
add_filter( 'relevanssi_page_builder_shortcodes', function( $shortcodes ) { $shortcodes[] = '/\[\/?tm_.*?\]/im'; $shortcodes[] = '/\[tm_slider_group.*?\].*\[\/tm_slider_group\]/im', return $shortcodes; } );Also, go save the front page or reindex with Relevanssi. If this works, then the front page shouldn’t show up in the search any more when you search for the slider content.
Sorry, no. This doesn’t change anything. I saved the front page and reindexed.
I still get this search result:
Startseite
…I“ image=“2359″ box_link=“url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fprofessionell-verkaufen-1%2F|title:Zum%20Kurs“ button=“url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fprofessionell-verkaufen-1%2F|title:Zum%20Kurs“ text=“Vertrieb Psychologische Grundlagen des menschlichen Verhaltens bei der Kommunikation im Verkaufsprozess“][tm_box_large_image style=“03″ xs_align=“center“ …Ok. Can you please show me the full source of the front page, with all the shortcodes? If I can see that, maybe I can figure out a solution, otherwise, I’d be just guessing blind and that’s a waste of time for both of us.
Sure. Good idea. Thank you.
[vc_row][vc_column][rev_slider slidertitle="Startseite" alias="startseite"][/vc_column][/vc_row][vc_row full_width="stretch_row"][vc_column][tm_spacer size="lg:40"][tm_heading custom_google_font="" align="center" line_height="1.4"]Institut für Wirtschaftspädagogik Ihr Partner für <mark>nachhaltigen Qualifizierungserfolg</mark> [/tm_heading][tm_spacer size="lg:40"][vc_row_inner content_placement="middle"][vc_column_inner width="2/3" lg_spacing="padding_right:50" sm_spacing="padding_right:10" xs_spacing="padding_right:10"][tm_heading tag="div" custom_google_font=""]Unsere 40-jährige Erfahrung in Verkauf und Führung, der Wille zur Steigerung der Entwicklungsziele sowie starkes Commitment der Teilnehmer sind der Motor unserer Trainings. Wir bieten Ihnen passgenaue Lösungen für eine kontinuierliche Weiterbildung, abgestimmt auf Ihren individuellen Bedarf. Unsere Kernkompetenz: Zukunftswirksame Trainingsinhalte und flexible, digitale und nachhaltige Lernformen. Entwickeln Sie die Potenziale Ihrer Mitarbeiter mit unseren Lernmodulen. Unsere Methoden und Werkzeuge motivieren, weil sie funktionieren: <b>Passion as a tool</b>. [/tm_heading][/vc_column_inner][vc_column_inner width="1/3" xs_spacing="padding_top:20"][tm_heading style="link-style-03" tag="div" custom_google_font="" font_size="xs:16"]<a href="https://iwp-training.de/individuelle-trainings/">Individuelle Trainings</a>[/tm_heading][tm_heading style="link-style-03" tag="div" custom_google_font="" css=".vc_custom_1639488098194{padding-top: 20px !important;}" font_size="xs:16"]<a href="https://iwp-training.de/kurse-trainings/">Unsere Kurse</a>[/tm_heading][tm_heading style="link-style-03" tag="div" custom_google_font="" css=".vc_custom_1639488104261{padding-top: 20px !important;}" font_size="xs:16"]<a href="https://iwp-training.de/digitale-lernwelten/">Digitale Lernwelten</a>[/tm_heading][/vc_column_inner][/vc_row_inner][tm_spacer size="xs:40;lg:80"][/vc_column][/vc_row][vc_section full_width="stretch_row" background_color="custom" background_repeat="repeat" background_size="auto" background_image="2567" custom_background_color="rgba(59,70,76,0.1)"][vc_row content_placement="middle" lg_spacing="padding_top:80;padding_bottom:80" xs_spacing="padding_top:40;padding_bottom:40"][vc_column lg_spacing="padding_right:135" offset="vc_col-lg-6 vc_col-md-5" md_spacing="padding_right:75" sm_spacing="padding_right:0"][tm_heading custom_google_font="" sm_align="center" line_height="1.4"]Individueller <mark>Bedarf</mark> - individuelles <mark>Training</mark>[/tm_heading][tm_spacer size="lg:40"][tm_heading tag="div" custom_google_font=""]Spezielle Situationen in der heutigen Arbeitswelt erfordern vielfältige Kompetenzen und flexible Lernformate. Wir beraten Sie und Sie wählen Ihre Trainingsbausteine aus. Nutzen Sie unsere Lernmodule für nachhaltige Weiterbildung, simultan zum Berufsalltag und entsprechend ihren Bedürfnissen.[/tm_heading][tm_spacer size="lg:40"][tm_button style="solid" button="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Findividuelle-trainings%2F|title:Mehr%20erfahren" xs_align="center" color="custom" font_color="custom" button_border_color="custom" button_bg_color_hover="custom" font_color_hover="custom" custom_font_color_hover="#ffffff" custom_font_color="#7b3f70" custom_button_border_color="#7b3f70" custom_button_bg_color_hover="#7b3f70"][/vc_column][vc_column offset="vc_col-lg-6 vc_col-md-7" sm_spacing="padding_top:40" xs_spacing="padding_top:20"][tm_grid columns="xs:1;sm:2;md:2;lg:2" column_gutter="md:30;lg:30" row_gutter="xs:1;md:20;lg:30"][tm_box_icon style="02" icon_type="fontawesome5" icon_fontawesome5="fal fa-chess-king-alt" icon_color="custom" custom_icon_color="#7b3f70" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fmanagement-und-fuehrung%2F|title:F%C3%BChrung%20%26%20Leadership" heading="Führung & Leadership" icon_font_size="xs:30;lg:35"][tm_box_icon style="02" icon_type="fontawesome5" icon_fontawesome5="fal fa-shopping-basket" icon_color="custom" custom_icon_color="#7b3f70" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Feinkauf%2F|title:Einkauf" heading="Einkauf" icon_font_size="xs:30;lg:35"][tm_box_icon style="02" icon_type="fontawesome5" icon_fontawesome5="fal fa-handshake" icon_color="custom" custom_icon_color="#7b3f70" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fvertrieb%2F|title:Vertrieb" heading="Vertrieb" icon_font_size="xs:30;lg:35"][tm_box_icon style="02" icon_type="fontawesome5" icon_fontawesome5="fal fa-chart-network" icon_color="custom" custom_icon_color="#7b3f70" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fakquise%2F|title:Akquise" heading="Akquise" icon_font_size="xs:30;lg:35"][tm_box_icon style="02" icon_type="fontawesome5" icon_fontawesome5="fal fa-comments" icon_color="custom" custom_icon_color="#7b3f70" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fkommunikation%2F|title:Kommunikation" heading="Kommunikation" icon_font_size="xs:30;lg:35"][tm_box_icon style="02" icon_type="fontawesome5" icon_fontawesome5="fal fa-cogs" icon_color="custom" custom_icon_color="#7b3f70" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Farbeitsprozesse%2F|title:Arbeitsprozesse" heading="Arbeitsprozesse" icon_font_size="xs:30;lg:35"][tm_box_icon style="02" icon_type="fontawesome5" icon_fontawesome5="fal fa-tasks" icon_color="custom" custom_icon_color="#7b3f70" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fprojektmanagement%2F|title:Projektmanagement" heading="Projektmanagement" icon_font_size="xs:30;lg:35"][tm_box_icon style="02" icon_type="fontawesome5" icon_fontawesome5="fal fa-theater-masks" icon_color="custom" custom_icon_color="#7b3f70" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fverhalten%2F|title:Verhalten" heading="Verhalten" icon_font_size="xs:30;lg:35"][/tm_grid][/vc_column][/vc_row][/vc_section][vc_row][vc_column][rev_slider slidertitle="Applaus Passion Störer" alias="applaus-passion"][/vc_column][/vc_row][vc_row full_width="stretch_row" disable_element="yes" background_image="2484" background_position="right"][vc_column][tm_spacer size="lg:138"][vc_row_inner content_alignment="right" xs_content_alignment="center" background_color="custom" max_width="600px" custom_background_color="rgba(245,245,245,0.8)" lg_spacing="padding_top:20;padding_right:20;padding_bottom:20;padding_left:20"][vc_column_inner][tm_heading custom_google_font="" font_weight="600" align="center" text_color="custom" custom_text_color="#7b3f70" line_height="1.34"]PASSION AS A TOOL[/tm_heading][tm_spacer size="lg:20"][tm_heading tag="div" custom_google_font="" align="center" text_color="custom" custom_text_color="#7b3f70" line_height="1.42" font_size="lg:25"]Wer arbeitet, wird seine Ziele erreichen. Wer sich begeistert, wird sie übertreffen.[/tm_heading][tm_spacer size="lg:60"][tm_button style="solid" button="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fkontakt%2F|title:Projekt%20starten" align="center" icon_type="fontawesome5" icon_fontawesome5="far fa-long-arrow-alt-right" color="custom" button_bg_color="transparent" font_color="custom" button_border_color="custom" button_icon_color="custom" button_bg_color_hover="custom" font_color_hover="custom" button_icon_color_hover="custom" custom_font_color_hover="#ffffff" custom_button_icon_color_hover="#ffffff" text_font_size="lg:20" icon_font_size="lg:20" custom_font_color="#7b3f70" custom_button_border_color="#7b3f70" custom_button_icon_color="#7b3f70" custom_button_bg_color_hover="#7b3f70"][tm_spacer size="lg:70"][/vc_column_inner][/vc_row_inner][tm_spacer size="lg:138"][/vc_column][/vc_row][vc_row full_width="stretch_row" background_size="auto" background_image="2535" background_position="bottom left"][vc_column][tm_spacer size="xs:40;lg:80"][tm_heading custom_google_font="" align="center"]Erfolgsfaktor Soft Skills - Ein Auszug unserer <mark>Kurse</mark>[/tm_heading][tm_spacer size="lg:40"][tm_slider_group content_shadow="01" pagination="01" gutter="30" auto_play="5000" items_display="xs:1;sm:2;md:3;lg:3" xs_spacing="padding_right:20;padding_left:20"][tm_box_large_image style="03" xs_align="center" el_class="hover" heading="Professionell verkaufen I" image="2359" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fprofessionell-verkaufen-1%2F|title:Zum%20Kurs" button="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fprofessionell-verkaufen-1%2F|title:Zum%20Kurs" text="<mark>Vertrieb</mark> Psychologische Grundlagen des menschlichen Verhaltens bei der Kommunikation im Verkaufsprozess"][tm_box_large_image style="03" xs_align="center" heading="Professionell verkaufen II" image="2360" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fprofessionell-verkaufen-2%2F|title:Zum%20Kurs" text="<mark>Vertrieb</mark> Kundenkommunikation mit der richtigen Strategie & Technik lenken" button="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fprofessionell-verkaufen-2%2F|title:Zum%20Kurs"][tm_box_large_image style="03" xs_align="center" heading="Professionell verkaufen III" image="2370" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fprofessionell-verkaufen-3%2F|title:Zum%20Kurs" text="<mark>Vertrieb</mark> Wirksame Dialoge & Einwandbehandlung für einen zielführenden Gesprächsabschluss" button="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fprofessionell-verkaufen-3%2F|title:Zum%20Kurs"][tm_box_large_image style="03" xs_align="center" heading="Vertriebsinnendienst" image="3981" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fvertriebsinnendienst%2F|title:Zum%20Kurs" text="<mark>Vertrieb</mark> Aktives Kundenmanagement als Wettbewerbsvorteil" button="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fvertriebsinnendienst%2F|title:Zum%20Kurs"][tm_box_large_image style="03" xs_align="center" heading="DIGITAL. sicher. auftreten" image="2361" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fdigital-sicher-auftreten%2F|title:Zum%20Kurs" button="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fdigital-sicher-auftreten%2F|title:Zum%20Kurs" text="<mark>Kommunikation</mark> Strukturierte & effiziente Online-Meetings moderieren & mit Ergebnissen abschließen"][tm_box_large_image style="03" xs_align="center" heading="Erfolgreich präsentieren" image="3936" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fpraesentation%2F|title:Zum%20Kurs" button="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fpraesentation%2F|title:Zum%20Kurs" text="<mark>Kommunikation</mark> Überzeugend auftreten bei Präsentationen & die Aufmerksamkeit des Publikums gewinnen"][tm_box_large_image style="03" xs_align="center" heading="Grundlagen der Kommunikation" image="3976" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fgrundlagen-kommunikation%2F|title:Zum%20Kurs" button="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fgrundlagen-kommunikation%2F|title:Zum%20Kurs" text="<mark>Kommunikation</mark> Effektive Kommunikation sicher & erfolgreich einsetzen"][tm_box_large_image style="03" xs_align="center" heading="Professionelle Kommunikation im Beruf" image="3972" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fprofessionelle-kommunikation-im-beruf%2F|title:Zum%20Kurs" button="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fprofessionelle-kommunikation-im-beruf%2F|title:Zum%20Kurs" text="<mark>Kommunikation</mark> Kommunikationstechniken im Arbeitsalltag professionell einsetzen"][tm_box_large_image style="03" xs_align="center" heading="West trifft Ost" image="2358" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Ferfolgreiche-zusammenarbeit-west-ost%2F|title:Zum%20Kurs" text="<mark>Kommunikation</mark> Chinesische Kultur & ihre Bedeutung bei der Zusammenarbeit mit chinesischen Kollegen" button="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Ferfolgreiche-zusammenarbeit-west-ost%2F|title:Zum%20Kurs"][tm_box_large_image style="03" xs_align="center" heading="DIGITAL. entspannt. sehen" image="2362" box_link="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fdigital-entspannt-sehen%2F|title:Zum%20Kurs" text="<mark>Mitarbeitergesundheit</mark> Erhalten Sie durch richtiges Augentraining Ihre Gesundheit & Konzentrationsfähigkeit" button="url:https%3A%2F%2Fbu2lgc.myraidbox.de%2Fdigital-entspannt-sehen%2F|title:Zum%20Kurs"][/tm_slider_group][tm_spacer size="lg:40"][tm_heading style="link-style-01" tag="div" custom_google_font="" align="center"]Herausforderungen sind lediglich getarnte Chancen. <a href="https://iwp-training.de/kurse-trainings/">Nutzen Sie die Chance!</a> [/tm_heading][tm_spacer size="xs:40;lg:80"][/vc_column][/vc_row][vc_row full_width="stretch_row" background_color="custom" lg_spacing="padding_top:80;padding_bottom:80" xs_spacing="padding_top:40;padding_bottom:40" custom_background_color="rgba(123,63,112,0.2)"][vc_column offset="vc_col-md-4"][tm_spacer size="xs:0;lg:40"][tm_heading custom_google_font=""]News & Aktuelles[/tm_heading][tm_spacer size="lg:40"][tm_heading tag="div" custom_google_font=""]Hier erhalten Sie regelmäßig spannende Einblicke in die Entwicklungen der Weiterbildungsbranche und andere aktuelle Themen.[/tm_heading][tm_spacer size="lg:20"][tm_heading style="link-style-03" tag="div" custom_google_font="" font_size="lg:16"]<a href="www.bu2lgc.myraidbox.de/news-aktuelles">Zu den aktuellen Themen </a>[/tm_heading][/vc_column][vc_column offset="vc_col-md-8" xs_spacing="padding_top:20"][tm_blog style="grid-classic" number="2" columns="xs:1;lg:2" column_gutter="lg:30" row_gutter="lg:30" taxonomies="category:news" xs_spacing="padding_right:20;padding_left:20"][/vc_column][/vc_row]-
This reply was modified 4 years, 1 month ago by
Steven Stern (sterndata).
I tested this so this should work:
add_filter( 'relevanssi_page_builder_shortcodes', function( $shortcodes ) { $shortcodes[] = '/\[tm_slider_group.*?\].*\[\/tm_slider_group\]/ims'; $shortcodes[] = '/\[\/?tm_.*?\]/ims'; return $shortcodes; } );The key here is the “/ims” instead of “/im”, which makes the search work across multiple lines.
Thank you so much. It works perfectly fine now. Your support is awesome. Thanks
I am having a similar issue with WPBakery. I had tried the code above and instead of using tm_ placed vc_.
The current search results includes shortcodes such as [vc_row][vc_column][stack_breadcrumbs][/vc_column][/vc_row][vc_row content_placement=”top”][vc_column width=”1/3″][vc_single_image image=”8976″ img_size=”205×205″ alignment=”center” style=”vc_box_rounded”…
Thanks in advance!
Instead of replying to resolved threads, please start a new thread.
Because Relevanssi already does WPBakery shortcode cleanup, try adding your function before the default action:
add_filter( 'relevanssi_page_builder_shortcodes', function( $shortcodes ) { $shortcodes[] = '/\[\/?vc_.*?\]/ims'; return $shortcodes; }, 6 );This might work better.
-
This reply was modified 4 years, 1 month ago by
The topic ‘Exclude Code from Search Results’ is closed to new replies.