Ready to get started?Download WordPress


Widget that provides recent posts from a category? (4 posts)

  1. bryan868
    Posted 7 years ago #

    How hard would it be to write a widget that provided the 5 latest posts from a particular category? Does anyone know of a widget like this that's already out there?

  2. drmike
    Posted 7 years ago #

    Look at one of the latest posts widget and replace the line containing the template call for the latest posts with one calling the latest posts for the specific category.

    You'd have to rename the functions as well so they don't be duped.

    Shouldn't be too hard.

  3. livemtl
    Posted 6 years ago #

  4. lloydarmbrust
    Posted 6 years ago #

    Well, I already answered this in another post, but here it is again:

     global $post;
     $myposts = get_posts('numberposts=5&offset=1&category=1');
     foreach($myposts as $post) :
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
     <?php endforeach; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.