Home Forums General Issues Pull in \"related\" posts excerpt? Reply To: Pull in \"related\" posts excerpt?

  • Sorry, that should have been acf/format_value filter. Looking at your other questions I will expand on it.

    add_filter('acf/load_value/type=relationship', 'get_extra_post_data', 20, 3);
    function get_extra_post_data($value, $post_id, $field) {
      if (empty($value)) {
        // no value to filter
        return $value;
      // this is needed because we will be working with excerpts
      global $post;
      foreach ($value as $post) {
        $post->excerpt = get_post_excerpt();
        $post->image = get_post_thumbnail();
      } // end foreach post
      // reset post data because we messed with the global
      return $value