Posted on

Indexing only some visible shortcodes

I am running another plugin, which uses custom fields that are visible, but I don’t want to include them in my search results. Is there a way to allow Relevanssi to continue index visible custom fields, but exclude few specific ones that I do not want indexed?

Yes: the list of custom fields is passed through the relevanssi_index_custom_fields filter hook. The filter hook gets an array of custom field names as the parameter, you can remove the ones you don’t like and return the rest.

Add this function to your theme functions.php:

add_filter('relevanssi_index_custom_fields', 'rlv_skip_custom_fields');
function rlv_skip_custom_fields($custom_fields) {
  $unwanted_fields = array('not_this_field', 'this_one_either');
  $custom_fields = array_diff($custom_fields, $unwanted_fields);
  return $custom_fields;

This question was originally asked on the plugin support forum.

One comment Indexing only some visible shortcodes

Leave a Reply

Your email address will not be published. Required fields are marked *