I’m trying to show my site stats in a static page, following snippet works on page templates. I would like to know how can I turn it to a shortcode so that I can paste it into any static page e.g. in “about us” page?
$total_posts = wp_count_posts( ‘post’ );
$total_posts = $total_posts->publish;
$total_cats = wp_count_terms(‘category’);
$total_comments = get_comment_count();
$total_comments = $total_comments[‘approved’];
echo ‘In our site there are ‘; echo $total_cats; echo ‘ cats; ‘; echo $total_posts; echo ‘ Posts and ‘; echo $total_comments; echo’ comments.’;