• Resolved ewwp

    (@ewwp)


    Hello Mikko!

    Awesome plugin, thanks for taking the time to create it. I do have a question, I have a page that has nested acf fields. While it’s finding the content and creating the excerpts, it’s also including the acf field id (field_590xxxxxxxxxx) in the search result excerpt.

    Example, I search student, on the search result page the created excerpt is “…special circumstances. field_5910ac8f46e2a Student field_5910ac3446e28 student field_5910ac4546e29 Please use this”

    It’s highlighting the search term in excerpt and everything is working so great, just wondering if it’s possible to not have the ACF Field id print in the search result excerpt as well?

    Thanks again!

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

    (@msaari)

    You’ve set Relevanssi to index all custom fields, which includes also the ACF meta data fields that contain field IDs as values. The solution would be to not index those meta data fields.

    With nested fields and the free Relevanssi, it’s hard if not impossible to choose to index just some custom fields and list the names of the fields you actually want to index (Premium helps a bit here), so you probably have to just index all fields, and then remove the ACF meta data fields with a filter.

    add_filter( 'relevanssi_index_custom_fields', 'rlv_remove_fields' );
    function rlv_remove_fields( $custom_fields ) {
        unset( $custom_fields['acf_meta_data_field_name'];
        return $custom_fields;
    }

    That would do the trick. You just have to find out the name of the ACF meta data field. You can do var_dump($custom_fields); exit(); in that filter function: go save a post and you’ll see a list of all custom fields for that post. You should be able to find the ACF meta data fields from that list.

    Thread Starter ewwp

    (@ewwp)

    Hi Mikko!

    Thanks for your reply, quick question though, once doing this, will I still be able to see that information show up without the field id meta data?

    Is that something the paid version would fix? Or by using this function, would I still be able not show the field id, but still show the result in the excerpt? Because the information it’s pulling from the field in search is still relevant.

    Thanks again for all your help, it’s so appreciated!

    Plugin Author Mikko Saari

    (@msaari)

    Premium will have this same issue –?this isn’t really about Relevanssi, this is about how ACF stores its data.

    This won’t affect the information: you’ll just remove the meta data fields, not the fields that contain the data. Those are unrelated. Relevanssi never indexes custom field names, unless you force it to on purpose.

    Actually, the easiest solution is to just make Relevanssi index visible custom fields, instead of all custom fields. All the ACF meta data fields are invisible.

    • This reply was modified 6 years, 3 months ago by Mikko Saari.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘ACF Field IDs showing in search excerpts’ is closed to new replies.