How to extend an array of WP post objects from ACF with TimberPost

I am using WordPress, Advanced Custom Fields, and Timber to build a theme. I am using an ACF relationship field to choose featured posts for one of my pages. This relationship field returns an array of WP post objects.

I grab this array and add it to my Timber $context with the following code:

/* featured posts */
$featured_posts = get_field(‘insights_featured_posts’);
$context[‘featured_posts’] = $featured_posts;

I would like each of the WP post objects within this array to be extended using Timber/Post. I am not sure the best way to accomplish this with an array of post objects. Any help would be appreciated.

This is my twig file that accesses the $featured_posts array:

{% for post in featured_posts %}
<div class=”col ns-col-is-4″>
<h3 class=”post-heading”>{{post.post_title}}</h3>
<p class=”post-content”>{{post.post_excerpt}}</p>
</div>
{% endfor %}

Read more here:: How to extend an array of WP post objects from ACF with TimberPost

Leave a Reply

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