Last active
August 29, 2015 13:59
-
-
Save thirdrev/10541166 to your computer and use it in GitHub Desktop.
WP Category Listing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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