Forums

LAST 10 Topics in the x category (5 posts)

  1. Mr.Hak
    Member
    Posted 10 months ago #

    hi all

    I Need LAST 10 Topics in the x category in Index.php THe Blocks

    I Need to the main blocks the down of the Index.php

    EX:
    block 1 Display cat 1
    block 2 Display cat 2
    block 3 Display cat 3 .....

    Thank you all

  2. filosofo
    Member
    Posted 10 months ago #

    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;
  3. Mr.Hak
    Member
    Posted 10 months ago #

    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

  4. filosofo
    Member
    Posted 10 months ago #

    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;
  5. Mr.Hak
    Member
    Posted 10 months ago #

    thanks alot

    Dissolved the problem and thanks you, my friend

    Quick question

    Is there an Plugins to this work

Reply

You must log in to post.

About this Topic

Tags

No tags yet.