Skip to content

Instantly share code, notes, and snippets.

@mglaman
Last active March 27, 2019 00:57
Show Gist options
  • Save mglaman/6117787 to your computer and use it in GitHub Desktop.
Save mglaman/6117787 to your computer and use it in GitHub Desktop.
Quick custom WP_Query to display all of a custom post type
<ul class="staff">
<?php $recentPosts = new WP_Query(array('posts_per_page' => -1, 'post_type' => array('staff') ));
while( $recentPosts->have_posts() ) : $recentPosts->the_post(); ?>
<li>
<div class="thumb"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('thumbnail') ?></a></div>
<p class="info vcard">
<span class="name"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
<span class="title"><?php the_field('job_title'); ?></span>
<span class="email"><a href="mailto: <?php the_field('email'); ?>"><?php the_field('email'); ?></a></span>
<span class="phone"><?php the_field('phone'); ?></span>
</p>
</li>
<?php endwhile;?>
</ul>
@NoshCode
Copy link

Thanks man.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment