[Plugin: Relevanssi – A Better Search] Show custom fields and excerpts
-
Hi, I’m using the excerpt filter to include a custom field “contents”. It works fine, but is it possible to only show the custom field in the excerpt if it contains a searched term?
Also, if the excerpt is pulling some text from the middle of a field (or normal contents) is it possible to have it preceded by three dots, like so: …some text that contains a term…
Thanks
Code I use now:
add_filter('relevanssi_excerpt_content', 'excerpt_function', 10, 3); function excerpt_function($content, $post, $query) { $fields = array('custom_contents', 'custom_designerName'); foreach($fields as $key => $field){ $field_value = get_post_meta($post->ID, $field, TRUE); $content .= 'Contents:<br />' . ( is_array($field_value) ? implode(' ', $field_value) : $field_value );} return $content; }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘[Plugin: Relevanssi – A Better Search] Show custom fields and excerpts’ is closed to new replies.