Support » Plugin: Relevanssi - A Better Search » Search specific fields (some custom)

  • I have a list of publications (custom post type) with a custom search form for them.

    In the search box they can select what fields to search: title, author(custom), & publication year(custom).

    Right now, I have it working to search all the fields and only publication posts. But im confused on the rest.

    Is that possible? If so, does it require the pro version?

    Im using the $query->query_vars method because this search is embedded in the publications archive page.

    I tried $query->query_vars[‘custom_field’] = array(‘author’, ‘pubdate’); and other forms of that.

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


    Yes, Premium version is required to search for terms in a particular custom field, the free version does not store that data.

    There are ways to do this in the free version as well, by filtering the hits with a filter function set on the relevanssi_hits_filter hook.


    So in the Premium version, how would you specify to search the title and publicationDate (custom meta)

    Or only publicationDate, and puclicationAuthor (custom meta).

    I see how I can do a general search where one custom meta field is x, but not searching in specific fields.

    Thanks again!

    Plugin Author Mikko Saari


    Thanks Mikko

    Can I search publicationAuthor and publicationDate (also custom meta) without searching anything else?

    I guess the hard part is that there is only one customfield_key, and I imagine I can not send an array to it.

    Plugin Author Mikko Saari


    That does get complicated in a way that is best dealt with using relevanssi_hits_filter to create a filter function that checks the custom fields in posts and weeds out the results where the custom fields don’t match.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Search specific fields (some custom)’ is closed to new replies.