Recent posts with date

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.

Code Snippet:

<li id="recent-posts" class="widget-container">
    <h3 class="widget-title">Uusimmat artikkelit</h3>
            $args = array( 'numberposts' => 3 );
            $postslist = get_posts( $args );
            foreach ($postslist as $post) :  setup_postdata($post); ?>
                <span><?php the_date(); ?></span>
                <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
        <?php endforeach; ?>

Posted in Posts