<?php
/*
 * Add recent posts shortcode. Use like so: [recent-posts posts='5' slug='uncategorized']
 */
 
function recent_posts_function($atts){
	extract(shortcode_atts(array(
		'posts' => 5,
		'slug' => 'uncategorized'
	), $atts));
 
	$return_string = '<ul>';
	query_posts(array('orderby' => 'date', 'order' => 'DESC' , 'showposts' => $posts , 'category_name' => $slug));
	if (have_posts()) :
		while (have_posts()) : the_post();
			$return_string .= '<h4><a href="'.get_permalink().'">'.get_the_title().'</a></h4>';
			$return_string .= '<p>'.get_the_excerpt().'</p>';
		endwhile;
	endif;
	$return_string .= '</ul>';
 
	wp_reset_query();
	return $return_string;
}
add_shortcode('recent-posts', 'recent_posts_function');