Support » Plugin: Relevanssi - A Better Search » Custom fields in excerpts

  • Resolved tomdxw



    We use Relevanssi at our company for quite a few sites, it’s a great plugin thank you.

    One issue that came up is that if we have a post type that has no post_content and only custom fields, relevanssi will index the custom fields but using the_excerpt() in the search loop will produce no output for these post types

    We’ve worked around that issue for the moment by checking the relevanssi_excerpt_content filter to see if it’s blank and adding the first custom field if it is, but of course this could be confusing to users if we show an excerpt that doesn’t contain their search term. So is there an option in relevanssi (or the premium version) that we’ve overlooked to show the custom field that matched the search terms rather than just post_content in the_excerpt()?

    Tom Adams

Viewing 1 replies (of 1 total)
  • Plugin Author Mikko Saari


    Well, that’s exactly how it is done – if you want Relevanssi to use custom fields for excerpts, you need to add the contents of the custom fields with the relevanssi_excerpt_content.

    What you’re doing wrong is adding the first custom field – always add all custom fields, no matter if the post content is empty or not. Relevanssi will use that data as a source for the excerpts, and will show the part that matches the search query.

Viewing 1 replies (of 1 total)
  • The topic ‘Custom fields in excerpts’ is closed to new replies.