Problem With relevanssi_excerpt_content filter
-
In my functions.php I have the following code which adds some external content from our newsletters to the search index:
add_filter('relevanssi_content_to_index', 'add_extra_content', 10, 2); add_filter('relevanssi_excerpt_content', 'add_extra_content', 10, 2); function add_extra_content($content, $post) { if( $post->post_type === 'newsletters' ) { $glink = get_post_meta($post->ID, 'html-attachment', true); if( ! empty( $glink ) ) { $txt = file_get_contents( 'https://jchwebdev.com/newsletters/' . $glink); if( ! empty($txt) ) $content .= $txt; } } return $content; }
For some reason, this is causing the search results to be incorrect for (apparently) a single page. What happens is that if I type in the search term ‘jchwebdev’ the first result is the home page (which makes sense) but the EXCERPT contains text pulled from one of the external newsletters–which makes no sense since they aren’t even the same post type. And this excerpt is not random; it’s the same every time. I’ve rebuilt the index and I get the same excerpt so what is going on with the filter that it’s pulling the wrong excerpt?
- The topic ‘Problem With relevanssi_excerpt_content filter’ is closed to new replies.