Skip to content

Instantly share code, notes, and snippets.

@LukeMichaels
Created December 18, 2015 01:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LukeMichaels/1a778554a7d00f602172 to your computer and use it in GitHub Desktop.
Save LukeMichaels/1a778554a7d00f602172 to your computer and use it in GitHub Desktop.
Loop posts from specific category 'cat' => 18 // the category ID # 'showposts' => 16 // the # of posts to display
/* remove `post_type` if not using a custom post type */
<?php query_posts( array( 'post_type' => 'your_category_title', 'cat' => 18, 'showposts' => 16 ) );
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><?php echo $post->post_title; ?></h2>
<p><?php the_content(); ?></p>
<a href="<?php echo get_permalink($post->ID); ?>">link</a>
<?php endwhile; endif; wp_reset_query(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment