Skip to content

Instantly share code, notes, and snippets.

@AmeliaBriscoe
Created May 27, 2014 03:17
Show Gist options
  • Save AmeliaBriscoe/8b03bd27ac06565712ad to your computer and use it in GitHub Desktop.
Save AmeliaBriscoe/8b03bd27ac06565712ad to your computer and use it in GitHub Desktop.
Display recent posts, with thumbnails, in the Thesis Classic Sidebar
/* Recent Posts With Thumbnails in Sidebar */
function recent_posts_thumb() {
global $post;
$thumbnails = get_posts('numberposts=5');
echo '<div class="recent-posts">';
echo '<p class="widget_title">Recent Posts</p>';
echo '<ul>';
foreach ($thumbnails as $thumbnail) {
if ( has_post_thumbnail($thumbnail->ID)) {
echo '<li>';
echo '<a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';
echo get_the_post_thumbnail($thumbnail->ID, array(50,50));
echo '</a>';
echo '<p><a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">'. esc_attr( $thumbnail->post_title ) .'</a></p>';
echo '</li>';
}
}
echo '</ul>';
echo '</div>';
}
add_action('thesis_hook_container_sidebar_top', 'recent_posts_thumb');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment