how to include only 2 acf fields and no cpt content
-
Hi! I do have a setup with facet wp and do use relevanssi as search engine. I just want to search in two acf fields “bezeichnung and artikelnummer” and no other field. i do checked the marked in index settings with my cpt products where these fields belong to and set “relevanssi_index_fields_select” to none.
then i made this code to include the 2 fields
add_filter( ‘relevanssi_index_custom_fields’, ‘rlv_include_custom_fields’ );function rlv_include_custom_fields( $custom_fields ) {
$included_fields = array( ‘bezeichnung’, ‘artikelnummer’ );
$custom_fields = array_merge( $custom_fields, $included_fields );
return $custom_fields;
}and to exclude products content
add_filter(‘relevanssi_index_custom_fields’, ‘exclude_custom_post_content’);function exclude_custom_post_content($custom_fields) {
if (is_singular(‘products’)) {
$custom_fields = array_diff($custom_fields, array(‘post_content’));
}
return $custom_fields;}
but products content is still searched. i also reindexed after code changes since as a facet user i am used to.
does anyboy have an idea?
thanks!
- The topic ‘how to include only 2 acf fields and no cpt content’ is closed to new replies.