Skip to content

Instantly share code, notes, and snippets.

@marisqaporter
Created February 29, 2016 21:10
Show Gist options
  • Save marisqaporter/c50403d5295e22b3e46f to your computer and use it in GitHub Desktop.
Save marisqaporter/c50403d5295e22b3e46f to your computer and use it in GitHub Desktop.
php loop with image as id - let's you call image size
<?php
$args = array(
'post_type' => 'volunteer-opportunit', // enter your custom post type
'orderby' => 'date', // order
'order'=> 'ASC', //reverse order
);
$loop = new WP_Query( $args );
if( $loop->have_posts() ):
echo '<div class="row stretch-xs center-xs">';
while( $loop->have_posts() ): $loop->the_post(); global $post;
echo '<div class="col-xs-12
col-sm-12
col-md-4
col-lg-4 row stretch-xs">';
?>
<div class="box staff-box volunteer-box">
<!-- the image -->
<?php
$size = 'volunteer';
$image = get_field('volunteer_image');
if( $image ) {
echo wp_get_attachment_image( $image, $size );
}
?>
<!-- the image -->
<?php the_title( '<h3>', '</h3>' ); ?>
</div>
<?php
echo '</div>'; //end section inner
endwhile;
echo '</div>'; //end row
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment