Skip to content

Instantly share code, notes, and snippets.

@dn7734
Created November 6, 2015 11:27
Show Gist options
  • Save dn7734/979f3bf6cad5599755dc to your computer and use it in GitHub Desktop.
Save dn7734/979f3bf6cad5599755dc to your computer and use it in GitHub Desktop.
sublime wordpress sage packery.sublime-settings
<snippet>
<content><![CDATA[
<section class="packery">
<div class="container">
<div class="row text-center">
<h2 class="heading-title">
<?php echo get_field('packery_title'); ?>
<span class="line-title"></span>
</h2>
<div class="filter">
<?php echo get_field('packery_text'); ?></div>
</div>
</div>
<div class="container container980">
<div class="row">
<div class="packery">
<?php
// check if the repeater field has rows of data
if( have_rows('packery') ):
// loop through the rows of data
while ( have_rows('packery') ) : the_row();
$image = get_sub_field('packery_image');
$url = get_sub_field('packery_post');
$the_post = get_post( $url );
$img_size = get_sub_field('packery_img_size');
switch ($img_size) {
case '1*1':
$size_test = 'one-thumb';
$class_test = 'col-md-3';
break;
case '1*2':
$size_test = 'two-thumb';
$class_test = 'col-md-3';
break;
case '2*1':
$size_test = 'three-thumb';
$class_test = 'col-md-6 packery-big-title';
break;
case '2*2':
$size_test = 'four-thumb';
$class_test = 'col-md-6';
break;
}?>
<div class="<?php echo $class_test; ?> item">
<a href="<?php echo $the_post->guid; ?>" class="overlay">
<div class="overlay-bg"></div>
<img src="<?php echo wp_get_attachment_image_src( $image, $size_test )[0];?>" alt="img" class="image-responsive">
<div class="content">
<span class="line"></span>
<h2 class="headin"><?php echo $the_post->post_title; ?></h2>
</div>
</a>
</div>
<?php
endwhile;
else :
// no rows found
endif;
?></div>
</div>
</div>
</section>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>wp-packery</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment