WordPress.org

Ready to get started?Download WordPress

Forums

LAST 10 Topics in the x category (5 posts)

  1. Mr.Hak
    Member
    Posted 5 years 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. Austin Matzko
    Member
    Posted 5 years 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 5 years 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. Austin Matzko
    Member
    Posted 5 years 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 5 years ago #

    thanks alot

    Dissolved the problem and thanks you, my friend

    Quick question

    Is there an Plugins to this work

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.