Note: You are viewing the documentation for Version 3View Version 4 Docs

Documentation

View the installation guide, browse the Knowledge Base, find out about SearchWP's many hooks, get support

Available since: 3.0

searchwp_acf_remove_field_references

View Parameters »

Note: Use of this hook will require a manual reindex

Advanced Custom Fields utilizes post meta (Custom Fields) to store internal data necessary for plugin functionality. This data is often useless when it comes to searching, so SearchWP allows you to tell it to disregard these field references if you’d like.

NOTE: There is potential for collision here based on how you have named your fields in ACF. SearchWP determines which field references to remove based on the registered fields you have in ACF. If one of your field names matches that of a Custom Field used by another plugin, you can inadvertently tell SearchWP to ignore a Custom Field that you do in fact want indexed. For example, if you’re using WooCommerce and Advanced Custom Fields, and you have an ACF field with the name of sku using this hook will cause WooCommerce SKUs to be removed because WooCommerce uses _sku to store SKUs.

See also: https://searchwp.com/docs/hooks/searchwp_acf_remove_field_reference/

<?php
// NOTE: See https://searchwp.com/docs/hooks/searchwp_acf_remove_field_references/
add_filter( 'searchwp_acf_remove_field_references', function( $remove, $context ) {
// TODO: Determine whether ACF field references should be removed.
return $remove; // true/false
}, 20, 2 );
view raw functions.php hosted with ❤ by GitHub

Parameters

Parameter Type Description
$remove Boolean

Whether to remove ACF field references

$context Array

$context['post_type'] The post type being indexed

Fix keyword search on your site. No coding required!

Now you can utilize all of the content that's gone unrecognized by native WordPress keyword search instantly with SearchWP

Get SearchWP