This plugin has to exist.... (6 posts)

  1. Clifton Griffin
    Posted 7 years ago #

    I'm setting up a wordpress blog for a guy who does motorcycle repairs. He is posting pictures of projects he is working on in a category called "Projects".

    I would like to display a list of "Recent Projects" on the main blog page at the top before the first post.

    This would not be unlike "recent news" and things other sites use. I have been searching for a few days for a plugin that can do this, but to now avail.

    Does anyone out there use a plugin like this or have any recommendations how I can accomplish this? I'm a fairly capable programmer so I'm not against doing something manual, but I feel confident that I'm not the first person to need this. I'd prefer not to reinvent the wheel!

    Much love,

  2. Dgold
    Posted 7 years ago #

    Sounds to me like what you want is....

    Display 10 Recent Posts from the "Projects" category.

    You can do this without a Plugin using some special code in The Loop (which is located in your Theme files).

    Something like this from the Codex, (read about it under Multiple Loops),


    <?php query_posts('category_name=PROJECTS&showposts=10'); ?>
      <?php while (have_posts()) : the_post(); ?>
        <!-- Do special_cat stuff like put the title and excerpt here... -->
      <?php endwhile;?>

    hope this helps ya get started

    there might be a plugin that handles it too

  3. Clifton Griffin
    Posted 7 years ago #

    Thanks for the info. I will probably end up using it.

    Anyone else out there seen anything that might be useful?

  4. Clifton Griffin
    Posted 7 years ago #

    Here is my finaly code. It ended up being fairly simple. Thank you for pointing me in the right direction.

    This code displays the 5 most recent posts from category 3 in a div at the top of the home page:

    <?php $count = 1 ?>
    <?php if ( is_home() ) { ?>
    <div style="width:inherit; background-color:#FFFFD9; border:dotted; border-color:#666; border-width:thin;">
    <h3 style="margin-left:5px;">Recent Projects</h3>
    <?php while (have_posts()) : the_post(); ?>
    <?php if ( in_category('3') && $count <= 5 ) { ?>
    <?php $count++; ?>
    <li style="margin-bottom:0px;"><h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5></li>
    <?php } ?>
    <?php endwhile;?>
    <?php } ?>
    <?php rewind_posts(); ?>
  5. Dgold
    Posted 7 years ago #

    Good job! Glad you got it working.

    That little line with "rewind_posts" is pretty important, eh!

  6. Clifton Griffin
    Posted 7 years ago #

    Well, I finally got around to making it into a plugin:


    Hopefully this will be helpful to others trying to do this.

Topic Closed

This topic has been closed to new replies.

About this Topic