I have this code to show recent posts from one category. I need to show only the posts which have comments. How can i do that via shortcode?
/* Shortcode to output recent posts from one category */
function display_cat_recent_posts() {
$args = array(
'post_type' => 'post',
'posts_per_page'=> 5,
'cat'=> 10,
);
$cat_recent_posts = new WP_Query( $args );
if( $cat_recent_posts->have_posts() ):
$output = '<ul>';
while ( $cat_recent_posts->have_posts() ) : $cat_recent_posts->the_post();
$output .= '<li><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></li>';
endwhile;
$output .= '</ul>';
endif;
return $output;
wp_reset_postdata();
}
add_shortcode( 'recent-posts', 'display_cat_recent_posts' );
Thank you...