Skip to content

Instantly share code, notes, and snippets.

@thirdrev
Last active August 29, 2015 13:59
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 thirdrev/10541166 to your computer and use it in GitHub Desktop.
Save thirdrev/10541166 to your computer and use it in GitHub Desktop.
WP Category Listing
<?php query_posts('cat=1&showposts=5'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
<?php the_excerpt() ?>
</li>
<?php endwhile; endif; ?>
and the second attempt:
<ul>
<?php
// The Query
query_posts( array ( 'category_name' => 'events', 'posts_per_page' => 10 ) );
// The Loop
while ( have_posts() ) : the_post(); ?>
<li>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php endwhile;
// Reset Query
wp_reset_query();
?>
</ul>
the third one I tried
<?php query_posts('cat=16&showposts=5'); ?>
<h2>Featured Posts</h2>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<li>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
<?php the_excerpt() ?>
</li>
</div>
<?php endwhile; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment