Title: Recent Posts Arguments?
Last modified: August 19, 2016

---

# Recent Posts Arguments?

 *  Resolved [motivatingfactor](https://wordpress.org/support/users/motivatingfactor/)
 * (@motivatingfactor)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-arguments/)
 * Hello,
 * I am building a theme: [http://organic-tote-bags.com/blog/](http://organic-tote-bags.com/blog/)–
   On the sidebar, I am displaying “Previous Posts” and I want the post date to 
   show on the left of the post title. I am currently displaying this information
   using the “Recent Posts” widget. But I will code it in the sidebar, so I can 
   achieve the desired effect, if needed.
 * I’m sure this is possible, I’m just not sure how to achieve this. Any assistance
   will be very much appreciated.
 * Very Best Regards,
    Richard

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-arguments/#post-981949)
 * Play with this:
 *     ```
       <?php
       $posts=get_posts('showposts=5');
       if ($posts) {
       foreach($posts as $post) {
       setup_postdata($post);
       ?>
       <p>by <?php the_author(); ?><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
       <?php }
       }
       ?>
       ```
   
 * Consider downloading and installing [Otto’s php code widget](http://wordpress.org/extend/plugins/php-code-widget/)
   and putting that code in one of those widgets:
 * Please remember to support our plugin authors by clicking on the Donate button
   there.
 *  Thread Starter [motivatingfactor](https://wordpress.org/support/users/motivatingfactor/)
 * (@motivatingfactor)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-arguments/#post-981984)
 * Hello MichaelH,
 * First of all, thanks for assisting me with this issue. I followed your instructions,
   however unfortunately it didn’t work. You can see the results of the provided
   php code, after being placed inside Otto’s widget here: [http://www.organic-tote-bags.com/blog/](http://www.organic-tote-bags.com/blog/)
 * Any ideas..
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-arguments/#post-981985)
 * What’s this:
    PREVIOUS POSTS * WINTER DARK * BUDS
 *  Thread Starter [motivatingfactor](https://wordpress.org/support/users/motivatingfactor/)
 * (@motivatingfactor)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-arguments/#post-982034)
 * Yes,
    * WINTER DARK * BUDS
 * are the previous posts I would like to display, having the post date on their
   left-side. They are currently being displayed, using the “Recent Posts widget”.
 * Beneath “Archives” you will see:
    by adminBUDS by adminBUDS
 * These are the results of the php code you provided, using Otto’s Plugin.
 *  [t31os](https://wordpress.org/support/users/t31os/)
 * (@t31os)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-arguments/#post-982042)
 * Try something like…
 *     ```
       <?php
       $posts=get_posts('showposts=5');
       if ($posts) {
       foreach($posts as $post) {
       setup_postdata($post);
       ?>
       <p><?php the_time('l, F jS, Y') ?> at <?php the_time() ?>
       <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
       <?php the_title(); ?></a>
       </p>
       <?php }
       }
       ?>
       ```
   
 *  Thread Starter [motivatingfactor](https://wordpress.org/support/users/motivatingfactor/)
 * (@motivatingfactor)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-arguments/#post-982055)
 * Ok, we are getting close. Below is the modified code I used:
 * <?php
    $posts=get_posts(‘showposts=5’); if ($posts) { foreach($posts as $post){
   setup_postdata($post); ?> <p>“><?php the_time(‘j.m.y’); ?> / <?php the_title();?
   ></p> <?php } } ?>
 * But it only shows the oldest post “Buds” twice. It is not showing each post. 
   How can I modify the above code to show each post and not the same post twice?
 * You can view the results here: [http://www.organic-tote-bags.com/blog/](http://www.organic-tote-bags.com/blog/)
   
   The results of the above code, appear beneath the heading “Test Code”
 *  Thread Starter [motivatingfactor](https://wordpress.org/support/users/motivatingfactor/)
 * (@motivatingfactor)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-arguments/#post-982056)
 * I got it,
 * Using the following:
 * <?php while (have_posts()) : the_post(); ?>
    <p>“><?php the_time(‘j.m.y’); ?>/
   <?php the_title(); ?>
   </p>
    <?php endwhile; ?>
 * Wow, the [Otto’s php code widget](http://wordpress.org/support/topic/241711?replies=7)
   Plugin is great, I was able to use the same php that I used in the content area
   of the theme.
 * Thanks for all your help t31os & MichaelH
 * Regards,
 *  [t31os](https://wordpress.org/support/users/t31os/)
 * (@t31os)
 * [17 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-arguments/#post-982057)
 * Welcome, i never tested the code… i just modified michaels….
 * Glad you got there in the end though…. 😉

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Recent Posts Arguments?’ is closed to new replies.

## Tags

 * [arguments](https://wordpress.org/support/topic-tag/arguments/)
 * [date](https://wordpress.org/support/topic-tag/date/)
 * [meh_code](https://wordpress.org/support/topic-tag/meh_code/)
 * [post date](https://wordpress.org/support/topic-tag/post-date/)

 * 8 replies
 * 3 participants
 * Last reply from: [t31os](https://wordpress.org/support/users/t31os/)
 * Last activity: [17 years, 3 months ago](https://wordpress.org/support/topic/recent-posts-arguments/#post-982057)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
