How to show Recent Posts by Category in Wordpress

In my Ask-Nik.info blog I wanted to display at the front page all the recent posts but not ordered by date.

I wanted to display every of my categories by 3 posts each. I've searched a lot of plugins but none did the job for me.

So I searched about a day how to do it by myself.

I finally manage to write a front page template which does this job for me. If you take a look at the Ask-Nik.info blog you will understand what I mean.

Here is the code :

<?php get_header(); ?>
	<div id="content" class="narrowcolumn">


	<?php

		$all_categor = get_all_category_ids();
		foreach($all_categor as $cat) :
			$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
			query_posts('paged='.$page.'&showposts=3&cat='.$cat);


	?>

			<?php while (have_posts()) : the_post(); ?>
				<div class="post" id="post-<?php the_ID(); ?>">
					<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
						<?php the_title(); ?>
					</a></h2>
					<small>
						<?php the_time('F jS, Y') ?>
						<!-- by <?php the_author() ?> -->
					</small>
					<div class="entry">
						<?php the_content('Read the rest of this entry »'); ?>
					</div>
					<p class="postmetadata">Posted in
						<?php the_category(', ') ?>
						|
						<?php edit_post_link('Edit', '', ' | '); ?>
						<?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
					</p>
				</div>
			<?php endwhile; ?>
			<?php if (have_posts()) : ?>
				<div class="navigation">
					<div class="alignleft">
						<?php next_posts_link('« Previous Posts on '. get_cat_name($cat)) ?>
					</div>
					<div class="alignright">
						<?php previous_posts_link('Next Entries on '. get_cat_name($cat) .' »') ?>
					</div>
				</div>
			<?php endif; ?>
		<?php endforeach; ?>
	</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

Trackback URL for this post:

http://www.igotanswers.info/trackback/64

updos prom hairstyles

anime giantess

take a look at our new blog -

[url=http://blogs.krify.com/giantess/] virtual giantess [/url]

http://blogs.krify.com/giantess/
[url=http://blogs.krify.com/giantess/] anime giantess [/url]

inuyasha and kagome in love together