Skip Navigation

[Escalated to 2nd Tier] "Include in search" for custom fields doesn't stay checked in a repeatable group

This support ticket is created 5 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 10 replies, has 2 voices.

Last updated by Christian Cox 5 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#1184410

BD
Screen Shot 2019-01-15 at 18.12.25.png
Screen Shot 2019-01-15 at 18.10.59.png

I am trying to get Relevanssi to search custom fields. I have set up the index and selected 'visible' for custom fields in Relevanssi (I have also tried 'All').

However, when I check the 'include in search' box of any Toolset custom field and then save the custom field group, the 'include in search' checkbox doesn't stay 'checked' (see screenshot). Neither does the custom field appear in the "Text search in custom fields" area.

The custom fields I am trying to include are within a repeatable group.

#1184478

Hi, check the discussion in this similar ticket: https://toolset.com/forums/topic/searching-keywords-from-repeating-field-group-is-not-working/page/2/#post-1152641

You must add the Repeating Field Group (as a post type) to the Relevanssi index. However, then you run the risk of direct links to each RFG post appearing as search results, which is probably not what you want. You probably want to show the parent post in the search results when there is a matching custom field value. This requires that you create a WordPress Archive for search, and add a conditional that detects the post type of each search result. When the post type matches the RFG, display the parent post's information. When it does not match the RFG, display the current post's information. I can help if this is confusing or you get stuck.

#1184976

BD
Screen Shot 2019-01-16 at 09.26.36.png

Thanks Christian - much appreciated. My first task will be for the fields to show up in the search - and unfortunately it's still not working. I have added the repeating group to the Relevanssi post type list (see screenshot) and re-archived - but it doesn't show up in search still. Also, under the column 'Excluded from search?', it still says 'yes'. How do you change this to 'no'? There's no apparent option in the custom group editing area...

Thanks, Nick

#1185181

The field checkbox state looks like a bug, but as long as you have added the custom field slug in the Relevanssi custom field index area the field can be indexed. To change the RFG to be searchable, you can add the following code to a child theme's functions.php file, or to a new snippet in Toolset > Settings > Custom code:

add_filter( 'wpcf_type', function( $post_type_options, $post_type ) {
    if( $post_type == 'faq-and-answers' ) {
        $post_type_options[ 'exclude_from_search' ] = false;
        $post_type_options[ 'publicly_queryable' ] = true;
    }

    return $post_type_options;
}, 10, 2 );

Note that the parent post type must be indexed as well as the RFG.

#1186008

BD

Thanks for your time on this Christian. Unfortunately I am no further along. In fact, when Relevanssi is activated, nothing appears in the search results at all now - not even pages and posts, so I have had to disable it.

I am working locally at the moment, but when the site is on the dev server, perhaps you could take a look to make sure I'm not missing anything?

Thanks again, Nick

#1186054

I'll take a look. Please add dev login credentials in the private reply fields here.

#1187727

Okay thanks, I am escalating this issue to my 2nd tier support team now. In my local tests, I'm able to access RFG custom field values in the Relevanssi search using the steps I described earlier, but for some reason yours isn't working the same way. I will try to get some feedback and give you an update as soon as I can.

#1188839

BD

Hi Christian - apologies but I forgot to let you have the front end password which I have had to reset so that the client can review the site. I have added it to the private message for your reference.

#1189160

Thanks for the update, I'll keep you posted here as I receive more information.

#1191898

BD

Hi Christian - I have added additional info to the private message. Thanks, Nick

#1192175

Thanks for the additional information. I'll keep you posted here, but there's nothing new to share just yet.