Skip to content

Instantly share code, notes, and snippets.

@jlittlejohn
Created October 10, 2012 19:05
Show Gist options
  • Save jlittlejohn/3867718 to your computer and use it in GitHub Desktop.
Save jlittlejohn/3867718 to your computer and use it in GitHub Desktop.
WP: Output Posts from Custom Post Type
<?php
$args = array( 'post_type' => 'my_post_type', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<h2>';
the_title();
echo '</h2><p>';
the_excerpt(); // the_content();
echo '</p><a href="';
the_permalink();
echo '" class="btn">Read more »</a>';
endwhile; wp_reset_postdata();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment