Exclude form data into excerpts
-
Hi,
I have a website where all the pages have a banner with the form on top. When I search for text, the results show up, but in the excerpt, the form select options are rendering. How do I exclude a certain div from searching?
The page I need help with: [log in to see the link]
-
See “Avoiding indexing menus” on https://www.relevanssi.com/knowledge-base/divi-page-builder-and-cleaner-excerpts/
Hi Mikko,
I have tried the below, but unable to excldue the form from the excerpt.
add_filter( 'relevanssi_post_content', 'rlv_remove_menu' ); add_filter( 'relevanssi_excerpt_content', 'rlv_remove_menu' ); function rlv_remove_menu( $content ) { $content = preg_replace( '~\[et_pb_fullwidth_code admin_label="Get in touch.*?\[/et_pb_fullwidth_code\]~ims', '', $content ); return $content; }Can you please help. This is the search url – https://www.y-axis.com/?s=canada+pr
Does this slightly wider version work?
add_filter( 'relevanssi_post_content', 'rlv_remove_menu' ); add_filter( 'relevanssi_excerpt_content', 'rlv_remove_menu' ); function rlv_remove_menu( $content ) { $content = preg_replace( '~\[et_pb_fullwidth_code.*?Get in touch.*?\[/et_pb_fullwidth_code\]~ims', '', $content ); return $content; }If not, can you check what the shortcode exactly looks like in the database? You can use this to check how Relevanssi sees the post: https://www.relevanssi.com/knowledge-base/debugging-indexing-problems/
Hi Mikko,
The code you have given didn’t help. Unable to exclude the form from top section.
I have added the debug code. You can see it here – https://www.y-axis.com/visa/work/canada/provincial-nominee-program/
You can see the output here – https://ibb.co/HpLVjps
It only shows the HTML of the page but no shortcodes. How do I Exclude the form on top? The form is on 90% of the pages. So all pages are showing the select dropdown options in the excerpt.
-
This reply was modified 5 years, 11 months ago by
jayaram558.
Try moving the filters to an earlier priority, ie. change the
add_filterpart to this:add_filter( 'relevanssi_post_content', 'rlv_remove_menu', 8 ); add_filter( 'relevanssi_excerpt_content', 'rlv_remove_menu', 8 );Does that help?
-
This reply was modified 5 years, 11 months ago by
Mikko Saari.
No Luck. it’s still the same.
If you change the code to this and then go save one of the posts with the form, what do you get?
add_filter( 'relevanssi_post_content', 'rlv_remove_menu', 8 ); function rlv_remove_menu( $content ) { var_dump($content); exit(); return $content; }Here is the results of what you asked – https://pastebin.com/52P16sfB
One more try:
add_filter( 'relevanssi_post_content', 'rlv_remove_menu', 8 ); add_filter( 'relevanssi_excerpt_content', 'rlv_remove_menu', 9 ); function rlv_remove_menu( $content ) { $content = preg_replace( '/\[et_pb_fullwidth_code.*?\].*\[\/et_pb_fullwidth_slider\]/im', '', $content ); return $content; }This will remove all
et_pb_fullwidth_codeelements, and matches what Relevanssi does to remove Divi stuff currently. (Usingimsmay actually be the problem, Relevanssi just usesim.)(I’m going to add this to the Relevanssi default behaviour in the next version.)
Hi Mikko,
Still no luck. its the same and rending the form in search results.
Are you sure those excerpts are generated by Relevanssi in the first place? If the excerpts are generated by Divi, then nothing you do with Relevanssi filters is going to change it. If you adjust the excerpt length, do the excerpts change?
I have changed 30 to 50 in Excerpts and highlights settings. But nothing has changed. Where do I update the settings?
IF the excerpts are created by divi, how do I change it?
Mikko,
Ok. I have changed truncate_post( 470 ); to the_excerpt(); in search.php and it worked now. Thanks, Much for your help!
One more quick question. I have selected to match the full word and unchecked OR fallback. But still, I get both the results. Why is that?
Example: if I search for Canada pr, I get results for Canada and also PR where if we have a word program, we get that into results. How do we make it an exact match?
-
This reply was modified 5 years, 11 months ago by
jayaram558.
If you haven’t touched the advanced indexing settings and adjusted the minimum word length from 3 to 2, “pr” is simply discarded and search for “canada pr” is just a search for “canada”. If you set the minimum word length to 2 and then reindex, the search should work as expected.
-
This reply was modified 5 years, 11 months ago by
The topic ‘Exclude form data into excerpts’ is closed to new replies.