Support » Plugin: Relevanssi - A Better Search » Dynamic custom field value is not found in search

  • Resolved Vane

    (@vanetreg)


    Hi,

    I have a custom post type (CPT) and its single page shows (visible) a custom field (CF) value of its parent CPT ( like a Book Author’s Name, where Name is the CF value, Author is a parent CPT and Book is a child CPT; and on the Book page also the Author Name is displayed).
    Relevanssi doesn’t display the content where the CF value is displayed (in the example: Name; R. only finds the Author CPT but not the Books), even if both Author and Book CPT is set to be indexed, all custom fields set to be indexed and index built after setting this up.
    Relevanssi’s Admin Search also doesn’t show those results.

    The CPTs and CFs are managed by Toolset and added to content templates (of CPTs) via block editor as dynamic content.
    I also explicitly selected in Toolset to allow these CFs to be indexed in Text Search,
    and rebuilt R. index after that.

    Any help is appreciated,
    thank you!

    • This topic was modified 10 months, 4 weeks ago by Vane.
    • This topic was modified 10 months, 4 weeks ago by Vane.
    • This topic was modified 10 months, 4 weeks ago by Vane.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Do I have this right? The parent post has a custom field, the child post displays it and you want Relevanssi to find the child post when searching for the content in the custom field the parent has?

    Relevanssi indexes the custom field for the post that actually has it, ie. the parent post. In order to index custom fields from another post, you need to add a relevanssi_content_to_index filter function that reads in the custom fields from the parent post when Relevanssi indexes the child.

    Relevanssi doesn’t understand the Toolset dynamic content.

    No, the parent post has a custom field (CF) and BOTH CPT display it ( both Author and Book ). When you display the Author Name on both Author (parent) and Book (child) CPT.
    More precisely: they are 2 CPTs in many-to-many Relationship, when a Book can have multiple Authors and an Author can have multiple Books.
    But Relevanssi only founds the CF string (Author Name) in the Author, but not in the Book CPT.
    Both Author and Book CPT is set to be indexed by R.
    Toolset dynamic content shouldn’t differ from standard WP dynamic content like archives, eg. category list, etc.

    • This reply was modified 10 months, 3 weeks ago by Vane.
    • This reply was modified 10 months, 3 weeks ago by Vane.
    Plugin Author Mikko Saari

    (@msaari)

    Ok, so what you say matches exactly what I said. What I said applies: Relevanssi indexes the custom field for the post that has the custom field, and you need to use a relevanssi_content_to_index filter hook to make Relevanssi index the parent custom field for the child, because Relevanssi doesn’t see the custom field as part of the child post in any way.

    Relevanssi generally doesn’t index WP dynamic content either, so at least that’s consistent.

    So neither the payed Pro/Premium version do that?

    Plugin Author Mikko Saari

    (@msaari)

    Both free and Premium do this the same way, and this is the only way to do it. Relevanssi can’t know how to connect custom fields from one post with a different post unless you explicitly tell it that it should.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Dynamic custom field value is not found in search’ is closed to new replies.