I use this code in functions.php
// recent posts shortcode/
// @ https://digwp.com/2018/08/shortcode-display-recent-posts/
function shapeSpace_recent_posts_shortcode($atts, $content = null) {
global $post;
extract(shortcode_atts(array(
'cat' => '',
'num' => '5',
'order' => 'DESC',
'orderby' => 'post_date',
'offset' => '',
), $atts));
$args = array(
'cat' => $cat,
'posts_per_page' => $num,
'order' => $order,
'orderby' => $orderby,
'offset' => $offset,
);
$output = '';
$posts = get_posts($args);
foreach($posts as $post) {
setup_postdata($post);
$output .= the_tags() .'';
}
wp_reset_postdata();
return ''. $output .'';
}
add_shortcode('recent_posts', 'shapeSpace_recent_posts_shortcode');
When I then use this shortcode: [recent_posts num="1" offset="0" cat="39"]
then I get the category name with a link to /tag/categoryname/
How do I modify the (bold line of) code so that I also get the total number of posts with this tag in this category, like this: uncategorized (5)
Something like this?
$output .= the_tags() .' <strong>('. count($a_variable) .')</strong>';
Thanks in advance
Anders