Skip to content

Instantly share code, notes, and snippets.

@nashvillegeek
Created November 19, 2013 14:50
Show Gist options
  • Save nashvillegeek/7546457 to your computer and use it in GitHub Desktop.
Save nashvillegeek/7546457 to your computer and use it in GitHub Desktop.
Sublime Text 2 Snippet: Advanced Custom Fields repeater loop with conditional
<snippet>
<content><![CDATA[
\$rows = get_field('${1:repeater-slug}');
if($rows)
{ ?>
<?php foreach(\$rows as \$row)
{ ?>
<div class="${3:twelvecol clearfix} ">
<h2><?php echo \$row['ng_acf_name']; ?></h2>
<img class="alignleft" src="<?php echo \$row['${1:repeater-slug}_image']; ?>" alt="" />
<ul>
<?php
if( \$row['ng_acf_undergraduate'])
{
echo '<li>${2:subfield_slug}: ' . \$row['${2:subfield_slug}'] . '</li>';
}
?>
</ul>
</div>
<?php
}
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>acfrepeater</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.php</scope>
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment