WordPress.org

Forums

Relevanssi - A Better Search
[resolved] Custom fields in excerpts (2 posts)

  1. tomdxw
    Member
    Posted 1 year ago #

    Hi,

    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
    dxw

    http://wordpress.org/plugins/relevanssi/

  2. Mikko Saari
    Member
    Plugin Author

    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.