WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Last 3 post on front page from one category? (4 posts)

  1. Originalas
    Member
    Posted 5 years ago #

    Can somebody explain how to put for example: 3 latest post from category "featured" to front page? Maybe not the whole post, but only the description (Excerpt).

  2. educationthemes
    Member
    Posted 5 years ago #

    <?php $recent = new WP_Query("cat=3&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    <?php the_excerpt(); ?>
    <?php endwhile; ?>

    Change cat=3 to the category ID you want to display 3 posts from.

  3. Originalas
    Member
    Posted 5 years ago #

    Cool! it works! :) Thanks

  4. rodoc
    Member
    Posted 5 years ago #

    But, if i want display last post of two categories, what put in cat="..." ???
    Thanks!!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.