Xmas

/ / Uncategorized

// Add Shortcode
function recent_posts_shortcode( $atts , $content = null ) {

// Attributes
$atts = shortcode_atts(
array(
‘subsubmenuid’ => ‘111’,
‘posts’ => ‘5’,
‘modelnumber’ => ‘lu1111’,
),
$atts,
‘recent-posts’
);

// Query
$the_query = new WP_Query( array ( ‘posts_per_page’ => $atts[‘posts’] ) );

// Posts
$output = ‘

    • ‘;

 

    • while ( $the_query->have_posts() ) :

 

    • $the_query->the_post();

 

    • $output .= ‘

    • ‘ . get_the_title() . ‘

‘;
endwhile;
$output .= ‘

‘;

// Reset post data
wp_reset_postdata();

// Return code
return $output;

}
add_shortcode( ‘recent-posts’, ‘recent_posts_shortcode’ );

Leave a Reply

Your email address will not be published. Required fields are marked *