WordPress.org

Ready to get started?Download WordPress

Forums

Last 5 posts in Category (5 posts)

  1. feverinlove
    Member
    Posted 7 years ago #

    hi, I would like to display lasts 5 posts from a category on the post page. I searched the forum but many lead to closed plugin pages. Could you help me?

    I am using Wp2

  2. alainS
    Member
    Posted 7 years ago #

    http://www.coffee2code.com/archives/2004/08/27/plugin-customizable-post-listings/

    and guess what? Just searching in wp forum with your post title gave me an answer.

  3. feverinlove
    Member
    Posted 7 years ago #

    I installed it but I couldnt get it work for different categories in different post pages

  4. feverinlove
    Member
    Posted 7 years ago #

    THIS SOLVED MY PROBLEM:

    <?php c2c_get_recent_posts(10, "%post_URL%
    ", "$cat", "date", "DESC", 0); ?>

  5. andrescristi
    Member
    Posted 6 years ago #

    I solved this problem by introducing an if in the loop.
    The code should be something like this:

    <?php
    			$cont = 0;
    			while (have_posts()) : the_post(); ?>
                <?php if($cont < 5){ ?>
    			<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                <?php the_content(); ?>
                <p class="postmetadata">Posted in <small><?php the_time('d \d\e F \d\e Y'); ?></small> under: <?php the_category(', '); ?>
    
                <?php $cont++; }?>
    			<?php endwhile;?>

    to me it works just fine.
    Any comments?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.