Skip to content

Instantly share code, notes, and snippets.

@justiny
Last active September 28, 2018 20:10
Show Gist options
  • Save justiny/37df29a29d52e4fd7d9046bec2caa1ab to your computer and use it in GitHub Desktop.
Save justiny/37df29a29d52e4fd7d9046bec2caa1ab to your computer and use it in GitHub Desktop.
Flexible Content in ACF & Timber
<?php
use Timber\Timber;
$context = Timber::get_context();
$context['post'] = $post;
$post = new TimberPost();
Timber::render( array(
'core/page-' . $post->post_name . '.twig',
'core/page.twig' ),
$context );
{# flexible content field name is es_layout #}
{% for item in post.get_field('es_layout') %}
{% if item.acf_fc_layout == 'hero' %}
{% include 'components/hero.twig' %}
{% elseif item.acf_fc_layout == 'hero_full_bg' %}
{% include 'components/three-col-blocks.twig' %}
{% endif %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment