Skip to main contentSkip to footer

On sites where ACF fields are used a lot, with Flexible Content and Repeater fields, it may be difficult to make Relevanssi only index the relevant ACF fields.

One way to deal with problem is to set Relevanssi to index “visible” custom fields and then restrict the indexed fields by field type. Add this function to your site to restrict the custom field indexing to only “text” type fields:

add_filter( 'relevanssi_index_custom_fields', function( $fields ) {
    $indexed_fields = array();
    foreach( $fields as $field ) {
        $object = get_field_object( $field );
        if ( is_array( $object ) && isset( $object['type'] ) && 'text' === $object['type'] ) {
            $indexed_fields[] = $field;
        }
    }
    return $indexed_fields;
} );

To control which field types are included, modify the “if” clause to include more field types.

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

Reading wpDataTables imported tables

The wpDataTables table plugin has several ways to handle tables. Some of them work with Relevanssi without problems; some don’t. You may notice that Relevanssi doesn’t index the entire table contents for wpDataTables tables (mainly imported tables). This is because the wpDataTables shortcode does not always expand to the entire…

Search shortcode

Relevanssi adds a shortcode to help making links to search results. That way users can easily find more information about a given subject from your blog. The syntax is simple: John Doe This will make the text John Doe a link to search results for John Doe. In case you…

ACF: Indexing ACF fields for taxonomy terms

…) { if ( ! isset( $term->term_id ) ) { return $content; // not a taxonomy term, skip } if ( isset( $term->term_id ) && ! isset( $term->taxonomy ) ) { // this is excerpt-building, where the taxonomy is in $term->post_type $term->taxonomy = $term->post_type; } $post_id = $term->taxonomy . ‘_’……won’t index these taxonomy custom fields because taxonomy terms aren’t generally allowed to have custom fields, and the default get_post_meta() function doesn’t work on taxonomy terms. Getting the fields indexed requires a bit of custom programming. You need to add a function to the relevanssi_tax_term_additional_content filter hook that reads the…Advanced Custom Fields makes it possible to add custom fields to taxonomy terms. You can only do this with Relevanssi Premium because the free version of Relevanssi can’t index taxonomy terms. Here’s how you would create a category field in ACF. Suppose you set Relevanssi to index custom fields. Relevanssi…

Related Posts:

Comment Section:

Leave a Reply

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

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed