Relevanssi - A Better Search
Search specific fields (some custom) (6 posts)

  1. ameyer
    Posted 2 years ago #

    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.


  2. Mikko Saari
    Plugin Author

    Posted 2 years ago #

    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.

  3. ameyer
    Posted 2 years ago #


    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!

  4. Mikko Saari
    Plugin Author

    Posted 2 years ago #

  5. ameyer
    Posted 2 years ago #

    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.

  6. Mikko Saari
    Plugin Author

    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Relevanssi - A Better Search
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic