Last active
May 18, 2018 15:31
-
-
Save megclaypool/cbc7f026b89e3a11c122dbcb3b06c754 to your computer and use it in GitHub Desktop.
Calling an External Twig File for an ACF Repeater Field How to include an external twig file for the contents of a repeater field. (WordPress, Twig, Timber, Advanced Custom Fields, ACF, Radicati)
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
Template: | |
{% if <codename-1> %} | |
<ul class="social-links-menu"> | |
{% for <codename-2> in <codename-1> %} | |
<li> | |
<a href="{{<codename-2>.<repeater-subfield>}}"> | |
{{ <codename-2>.<some-other-repeater-subfield> }} | |
</a> | |
</li> | |
{% endfor %} | |
</ul> | |
{% endif %} | |
Example: | |
{% if media %} | |
<ul class="social-links-menu"> | |
{% for item in media %} | |
<li> | |
<a href="{{item.awardee_social_media_link}}"> | |
{{ item.awardee_social_media_title }} | |
</a> | |
</li> | |
{% endfor %} | |
</ul> | |
{% endif %} |
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
Template: | |
{% include "<path-to-external-twig-file>.twig" with | |
{'<codename-1>': <repeater-field>} %} | |
Example: | |
{% include "widgets/social-media.twig" with | |
{'media': post.get_field('awardee_social_media')} %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment