• Posted: 2011-03-30
  • Author: Titiu Nylund
  • Tags:

Recent posts with date

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
<li id="recent-posts" class="widget-container">
    <h3 class="widget-title">Uusimmat artikkelit</h3>
    <ul>
        <?php
            $args = array( 'numberposts' => 3 );
            $postslist = get_posts( $args );
            foreach ($postslist as $post) :  setup_postdata($post); ?>
            <li>
                <span><?php the_date(); ?></span>
                <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
            </li>
        <?php endforeach; ?>
    </ul>
</li>

Instructions:

This simply shows your recent posts with dates in your template. Sometimes the build-in WP Recent Posts isn’t enough and other available widgets seem too complicated when you want to show just a date and a post title with link.

Post this in your sidebar.php before or after your dynamic sidebar.


Share this snippet

If you like this snippet, share it with friends!