* Author: Nick van de Veerdonk
* Author URI: https://jaaadesign.nl/
*/
function amp_recent_function($atts, $append, $heading) {
if (is_single() && !is_page()) {
extract(shortcode_atts(array(
'append' => 'amp',
'heading' => null,
'max' => 10,
), $atts));
$return_string = '
';
query_posts(array('orderby' => 'date', 'order' => 'DESC', 'showposts' => $max, 'append' => $append, 'heading' => $heading));
$return_string = ''.$heading.'
';
if (have_posts()) :
while (have_posts()) : the_post();
$return_string .= '- '.get_the_title().'
';
endwhile;
endif;
$return_string .= '
';
wp_reset_query();
return $return_string;
}
}
function register_shortcode_amp_rec(){
add_shortcode('amp-recent-posts', 'amp_recent_function');
}
add_action( 'init', 'register_shortcode_amp_rec');