Title: Exclude ACF Fields in post_excerpt
Last modified: October 30, 2020

---

# Exclude ACF Fields in post_excerpt

 *  [mdrick](https://wordpress.org/support/users/wicko77/)
 * (@wicko77)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/exclude-acf-fields/)
 * Hello,
 * Really good job for this plugin.
 * I would like to know if it’s possible to exclude some ACF fields in the `post_excerpt`
   output ?
 * All works fine but I created an agenda with events. And Relevanssi add date from
   ACF fields in `post_excerpt` output
    -  This topic was modified 5 years, 5 months ago by [mdrick](https://wordpress.org/support/users/wicko77/).
    -  This topic was modified 5 years, 5 months ago by [mdrick](https://wordpress.org/support/users/wicko77/).

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/exclude-acf-fields/#post-13604072)
 * By default Relevanssi uses the same custom fields for indexing and excerpts. 
   If you remove a custom field from the indexing settings, it will be removed from
   the excerpts as well. Perhaps you can remove the date field from being indexed?
 * Another option is to use the `relevanssi_excerpt_custom_field_content` filter
   hook to adjust the custom field content before it’s added to the excerpts.
 *  Thread Starter [mdrick](https://wordpress.org/support/users/wicko77/)
 * (@wicko77)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/exclude-acf-fields/#post-13605977)
 * Hello thank you very much for your answer.
 * If I declare custom fields with `relevanssi_excerpt_custom_field_content` hook,
   only these fields will be used ?
 * I don’t have more detail about this hook in the documentation. What parameters
   does this hook accept?
 * What’s the difference with `relevanssi_excerpt_content` ?
 *     ```
       function custom_fields_to_excerpts($content, $post, $query) {
       	$custom_field = get_post_meta($post->ID, 'article_technics_repeater', true);
           $content .= " " . $custom_field;
           $custom_field = get_post_meta($post->ID, 'article_wysiwyg', true);
           $content .= " " . $custom_field;
           return $content;
       }
   
       add_filter('relevanssi_excerpt_content', 'custom_fields_to_excerpts', 10, 3);
       ```
   
 * It is possible to hide link in content. I got [https://www.soundcloud.com&#8230](https://www.soundcloud.com&#8230);
   for example ?
 * Thank you in advance
    -  This reply was modified 5 years, 5 months ago by [mdrick](https://wordpress.org/support/users/wicko77/).
    -  This reply was modified 5 years, 5 months ago by [mdrick](https://wordpress.org/support/users/wicko77/).
    -  This reply was modified 5 years, 5 months ago by [mdrick](https://wordpress.org/support/users/wicko77/).
    -  This reply was modified 5 years, 5 months ago by [mdrick](https://wordpress.org/support/users/wicko77/).
    -  This reply was modified 5 years, 5 months ago by [mdrick](https://wordpress.org/support/users/wicko77/).
    -  This reply was modified 5 years, 5 months ago by [mdrick](https://wordpress.org/support/users/wicko77/).
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/exclude-acf-fields/#post-13606388)
 * First, all Relevanssi filter hook documentation is here: [https://www.relevanssi.com/user-manual/filter-hooks/](https://www.relevanssi.com/user-manual/filter-hooks/)
 * All hooks are also documented in the source code.
 * `relevanssi_excerpt_custom_field_content` is not for declaring custom fields;
   there’s no function for that (well, there’s `relevanssi_index_custom_fields`,
   but it applies both in indexing and in excerpts; I suppose there should be also`
   relevanssi_excerpts_custom_fields` for filtering the actual fields). The `relevanssi_excerpt_custom_field_content`
   lets you filter the custom field content as a single concatenated string. That’s
   the only parameter, so it’s fairly basic.
 * The difference to `relevanssi_excerpt_content` is that `relevanssi_excerpt_content`
   has all content, while `relevanssi_excerpt_custom_field_content` only has the
   custom field content, so if you want to focus on that, this is a more specific
   function. If you want to add content from specific custom fields (note that indexed
   custom fields are generally automatically used for excerpts, if you just check
   that option in Relevanssi settings), then `relevanssi_excerpt_content` is better
   for that.
 * To hide the links, it’s probably best to filter them out in one of these hooks.
 *  Thread Starter [mdrick](https://wordpress.org/support/users/wicko77/)
 * (@wicko77)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/exclude-acf-fields/#post-13607345)
 * Thank you for taking the time to explain this to me.
 * I’m a little confused.
 * What is your advice for building an excerpt with only selected custom fields (
   in addition to `the_content` from WordPress).
 * I tried to set `Custom fields` option to `some` in `indexing` tab but I still
   have results with custom fields that I don’t want.
 * I tried to set `Custom fields` to `visible` and I have these famous date fields
   that appear in the excerpt.
    -  This reply was modified 5 years, 5 months ago by [mdrick](https://wordpress.org/support/users/wicko77/).
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/exclude-acf-fields/#post-13608572)
 * Relevanssi should only use the fields listed in the Custom fields setting for
   excerpts.
 * This problem does sound familiar; I seem to remember someone else having problems
   with ACF adding unwanted fields to the excerpts. Unfortunately that’s about all
   I remember of it.
 * What is the name of the date field that is being added to the excerpt? Are the
   excerpts otherwise exactly as set in the Relevanssi settings? If you disable 
   Relevanssi custom excerpts, the date is not being added in the excerpt?
 *  Thread Starter [mdrick](https://wordpress.org/support/users/wicko77/)
 * (@wicko77)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/exclude-acf-fields/#post-13609539)
 * For an agenda I created two custom date fields with ACF.
    A start date `event_hour_start`(
   datepicker) and an end date `event_hour_end` (datepicker).
 * If I use the `some` option or `visible` I don’t have any excerpts.
 * When I use `relevanssi_excerpt_content` hook it works but I don’t have fields
   in flexible content, I tried to use `blocs_article_$_article_wysiwyg` and `blocs_article_%
   _article_wysiwyg` syntax without success. Maybe I need to reindex when I change
   options?
 * If I disable Relevanssi custom excerpts (I uncheck `Create custom search result
   snippets`). I no longer have the dates (and obviously no longer any excerpt).
    -  This reply was modified 5 years, 5 months ago by [mdrick](https://wordpress.org/support/users/wicko77/).
    -  This reply was modified 5 years, 5 months ago by [mdrick](https://wordpress.org/support/users/wicko77/).
    -  This reply was modified 5 years, 5 months ago by [mdrick](https://wordpress.org/support/users/wicko77/).
    -  This reply was modified 5 years, 5 months ago by [mdrick](https://wordpress.org/support/users/wicko77/).
    -  This reply was modified 5 years, 5 months ago by [mdrick](https://wordpress.org/support/users/wicko77/).
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/exclude-acf-fields/#post-13610006)
 * What if you make Relevanssi index all custom custom fields (though just `visible`
   should work; ACF stores actual data in visible fields and useless metadata you
   don’t want to index in hidden fields), and then add this:
 *     ```
       add_filter( 'relevanssi_index_custom_fields', 'rlv_remove_dates' );
       function rlv_remove_dates( $fields ) {
           $remove = array( 'event_hour_start', 'event_hour_end' );
           return array_diff( $fields, $remove );
       }
       ```
   
 * Does this work? Reindexing is not necessary for changes to appear in excerpts.
 *  Thread Starter [mdrick](https://wordpress.org/support/users/wicko77/)
 * (@wicko77)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/exclude-acf-fields/#post-13616890)
 * It’s perfect. It works very well. Thank you to have taken the time to answer 
   and find a solution.
 * I have 0 or 1 that appear at the beginning of some excerpt. Could it be because
   of true/false custom fields?
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/exclude-acf-fields/#post-13618535)
 * Yes, that does sound like a boolean field.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Exclude ACF Fields in post_excerpt’ is closed to new replies.

 * ![](https://ps.w.org/relevanssi/assets/icon-256x256.png?rev=2025044)
 * [Relevanssi - A Better Search](https://wordpress.org/plugins/relevanssi/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/relevanssi/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/relevanssi/)
 * [Active Topics](https://wordpress.org/support/plugin/relevanssi/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/relevanssi/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/relevanssi/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/exclude-acf-fields/#post-13618535)
 * Status: not resolved