The following will print a list of the last 10 posts for every category:
foreach( (array) get_all_category_ids() as $cat_id ) :
query_posts(array('cat' => $cat_id, 'showposts' => 10));
if ( have_posts() ) :
?><h2><?php echo get_cat_name($cat_id); ?></h2>
<ul>
<?php while(have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
<?php
endif;
endforeach;
Thread Starter
mrhak
(@mrhak)
Thes code Is Ready
<?php foreach( (array) get_all_category_ids() as $cat_id ) :
query_posts(array('cat' => $cat_id, 'showposts' => 10));
if ( have_posts() ) :?><h2><?php echo get_cat_name($cat_id); ?></h2>
<ul>
<?php while(have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
<?php endif; endforeach; ?>
thanks friend
put i need to show onr cat Only
Plz help me all
If you need just one category, then do this:
$cat_id = 2; // "2" is the category id for the category you want
query_posts(array('cat' => $cat_id, 'showposts' => 10));
if ( have_posts() ) :
?><h2><?php echo get_cat_name($cat_id); ?></h2>
<ul>
<?php while(have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
<?php
endif;
Thread Starter
mrhak
(@mrhak)
thanks alot
Dissolved the problem and thanks you, my friend
Quick question
Is there an Plugins to this work