With the latest version (4.18.3, out yesterday), excluding the Repeater field will exclude all the sub fields. With earlier versions, nothing got excluded.
The names are probably coming to the excerpt from custom fields. ACF stores the names of the fields in other fields. Are you using “all” or “visible” custom fields? The field names are stored in the invisible fields, so you should be using “visible”.
I confirmed that we are set to show only “visible” ACF fields, but the layout names are still appearing in our search results. What more can I check, please?
You can use this filter hook to examine the custom field content used in the excerpts. It also provides you with a list of custom field names Relevanssi gets the content from. That would be a good place to start.
Again, these are NOT custom field values, they’re the names of the layouts that contain the custom fields. Not sure this still applies?
Well, they’re coming from somewhere. Relevanssi looks at post content and custom fields. ACF stores custom field names in custom fields, so you definitely can get custom field names in excerpts from ACF custom fields. I do recommend you use that filter hook to see what content is coming from the fields.
I’m sorry, I don’t understand how this is used or how it can filter out layout names. This seems to demonstrate how you could use just one particular field for your excerpts. Is there additional documentation to explain how to filter OUT layout names?
add_filter( 'relevanssi_excerpt_custom_field_content', function ( $content, $post_id, $custom_fields ) {
var_dump( $custom_fields );
return $content;
}, 10, 3 );
This will print out the list of custom fields Relevanssi uses to create the excerpts. Does this list contain custom fields that have these layout names as values? In ACF, these are usually the fields that begin with underscores. Does the list include any underscore fields? If it does, that’s probably the problem.
Thanks for that snippet. I’m not sure how to tie the two together. Here’s the search page with the var dump turned on: https://benustaging.wpengine.com/?s=library
If you look at the excerpt for “Library Hours” it contains a lot of layout names. One of them is “hero2”. But there’s no “hero2” in the var dump — should the values be in the var dump as well?
No, the dump only has the field names. Most of them seem relevant, but then you have fields like these: visit_campus_0_acf_hide_layout. You’re also indexing lots of button links, images, color codes and things like that.
I’d go through your ACF fields in the ACF field group settings and check the “Exclude from Relevanssi index” for all fields that have something else than text you know you want indexed. That will remove those fields from the excerpts as well. Does that help?
I’m sorry, we’re miscommunicating somehow. I have already chosen to hide a very large number of ACF *field values* from the excerpts; that works fine. The remaining unwanted strings are the NAMES of Flexible Content LAYOUTS. As such, they do not have “hide” buttons or fields & values associated with them, themselves. They are containers, if you will. They are one level higher — a flexible content layout is a “parent” container with a group of ACF fields & values within it.
If, for example, the section layout called “hero2” has been used on a particular page, the page template will loop through that layout’s fields & values. Those fields & values can be hidden easily, using your toggle switch. But we’re seeing the layout name “hero2” appear in our excerpt. This is happening for all flexible content LAYOUT NAMES, and I’m trying to understand how to hide them.
Please let me know if that’s making sense to you. Thanks again for your help.
The names of the layouts are also stored in custom fields. If your flexible content field is named “flexi_field” and it has a layout “hero2”, there’s a custom field called “flexi_field”, which has the word “hero2” in it. That’s where Relevanssi can fetch it to the excerpt, and that’s what needs to be blocked.
Relevanssi should automatically block fields with the field types repeater, flexible_content and group from the index and excerpts to avoid this very problem, but it looks like that is not working in your case.
So, what is the name of the Flexible Content field that contains the “hero2” layout? Does that name appear in the var_dump() output?
“…there’s a custom field called “flexi_field”, which has the word “hero2” in it”
Maybe I’m not making the connection between the search results page and the pages for which Relevanssi is creating the excerpts that contain layout names.
On the search results page, your code snippet is providing a var dump; however, the string “hero2” is found nowhere except in the excerpt — it’s not in the var dump anywhere:
view-source:https://benustaging.wpengine.com/?s=library
On an example page, for which Relevanssi is creating a problematic excerpt, there is no var dump to see, and there’s no way for me to see what “hidden” ACF field might contain the layout name “hero2”:
view-source:https://benustaging.wpengine.com/library/hours/
Looking at these two pages, how am I supposed to find the ACF field containing the layout name that needs to be hidden? I will need to track down close to 100 of these layout names, which are appearing in our search results. The client is very unhappy about this…it looks very unprofessional.
You can see this from the ACF field settings. What is the Flexible Content field name that has the “hero2” layout? That’s the custom field name that contains the word “hero2” and where Relevanssi is getting that word to the excerpt.
Looking at the shorter list of field names at https://benustaging.wpengine.com/?s=%22Opening%20Interfaith%20Convocation%22, I’d guess “flexible_content2” is the name of the Flexible Content custom field, with the names of all the layouts in it.
Are you using any custom functions for controlling which ACF fields are included and which are not? The current version of Relevanssi should ignore all Flexible Content fields, but if you have some custom functions related to this, it may be interfering.
You’re right, the flexible content field “flexible_content2” contains the “hero2” layout (and many other layouts).
We’re basically using ACF by the book. If layout 1, spit out layout1; elseif layout2, spit out layout2.
We do have a plugin installed that allows you to hide/show flexible content layouts, but deactivating the plugin has no effect on the rogue excerpts — the layout names are still there.
What do you suggest we check next?
Earlier in the thread you were using a filter function on relevanssi_index_custom_fields. Are you still doing that, or are you only using the new “exclude from Relevanssi index” functionality to control the ACF fields? If you are using a filter function, please show me what you have.