Last active
September 28, 2018 20:10
-
-
Save justiny/37df29a29d52e4fd7d9046bec2caa1ab to your computer and use it in GitHub Desktop.
Flexible Content in ACF & Timber
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# 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