Created
January 16, 2015 06:05
-
-
Save raewrites/9752e257ce33d2f210ec to your computer and use it in GitHub Desktop.
List of Recent Posts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
'posts_per_page' => '4', | |
'exclude' => array( $post->ID ) | |
); | |
// get posts | |
$posts = get_posts( $args ); | |
// check if any posts are returned | |
if ( $posts ) { ?> | |
<section class="recent-posts clear"> | |
<?php foreach ($posts as $post ) { ?> | |
<?php setup_postdata( $post ); ?> | |
<article id="post-<?php the_ID(); ?>" <?php post_class( 'left' ); ?>> | |
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> | |
<?php post_thumbnail( 'thumbnail' );?> | |
</a> | |
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> | |
<?php the_title(); ?> | |
</a> | |
</article> | |
<?php } ?> | |
</section> | |
<?php } | |
/* Restore original Post Data */ | |
wp_reset_postdata(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment