Skip to content

Instantly share code, notes, and snippets.

@webmasterninjay
Created January 16, 2019 15:41
Show Gist options
  • Save webmasterninjay/4c39d5d4e94009c79efd57eaf7905dd4 to your computer and use it in GitHub Desktop.
Save webmasterninjay/4c39d5d4e94009c79efd57eaf7905dd4 to your computer and use it in GitHub Desktop.
loop-shortcode.php
<?php
function team_member_loop( $atts ) {
ob_start();
$args = array(
'post_type' => 'team-member',
'showposts' => 99,
'order' => 'ASC',
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) { ?>
<div class="team-member-loop">
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<?php
$position = types_render_field('position',array('raw'=>'true'));
$email = types_render_field('email',array('raw'=>'true'));
?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( has_post_thumbnail() ) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark">
<?php the_post_thumbnail( 'thumbnail', array( 'class' => 'alignleft' ) ); ?>
</a>
<?php endif; ?>
<div class="hr-entry-title">
<h2><a href="mailto:<?php echo $email; ?>"><?php the_title(); ?></a> <small><?php echo $position; ?></small></h2>
</div>
<div class="hr-entry-content">
<?php the_content(); ?>
</div>
</div>
<?php endwhile;
wp_reset_postdata(); ?>
</div>
<?php $thepost = ob_get_clean();
return $thepost;
}
}
add_shortcode('team_member_loop', 'team_member_loop');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment