• Hi I have a post called Item with a many to many relationship with a post called Authority. I would like to include a search field where if any word in the custom fields is searched, the Item post will be displayed. I have done the following:

    Included authority and item-authority (relationship) in the post types and saved. Created the index.

    Changed custom fields to some and included all custom fields from Item and all custom fields from Authority:

    wpcf-amount-of-digitised-material, wpcf-archdiocese-digitisation-project-no, wpcf-begin-year, wpcf-box-no, wpcf-country, wpcf-creator, wpcf-end-year, wpcf-extent-of-record, wpcf-features, wpcf-hmml-project-no, wpcf-inventory-no, wpcf-inventory-title, wpcf-notes, wpcf-related-material, wpcf-scope-and-content, wpcf-shelf-location, wpcf-supplied-title, wpcf-authority-name, wpcf-biography-information, wpcf-events-highlights, wpcf-range, wpcf-related-corporate-body, wpcf-related-geographic-places, wpcf-related-person, wpcf-variants, wpcf-reference
    All these fields have Include in search tickbox selected.

    I included a search box In the Archive of Item where it has to gather data from Title, body and custom fields. It is currently working for Item search fields but not for the related Authority records.

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

    (@msaari)

    Relevanssi in general does not automatically handle relationship fields, because usually, these fields contain post IDs. Relevanssi sees the post ID, but nothing else.

    What you need is some code that hooks on the indexing process and when indexing the Item, it expands the relationship field to include content from the Authority.

    Here’s an example with ACF relationships, that should give you a clue.

    Thread Starter katia88

    (@katia88)

    What are the 10 and 2 paramaters referring to? Where should this function be placed and where should it be called?

    • This reply was modified 2 years, 8 months ago by katia88.
    Plugin Author Mikko Saari

    (@msaari)

    10 is the priority and 2 is the number of arguments, see add_filter() documentation.

    The function (but not this one, because you need to customize whatever you use to your specific use case) can be placed anywhere it’ll be executed – theme functions.php is typical, or a code snippet if you use code snippet plugins. It’s a filter function, so it doesn’t need to be called, Relevanssi will use it when indexing if the function is available.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Relevanssi relationship’ is closed to new replies.