Displaying Total Number of Posts and Comments on the WordPress Website
Notice
If you want to display the total number of categories, articles and comments anywhere on your site, these codes will be useful for you. I haven’t been able to post consistently on my site for months now. I didn’t post much on social media either. However, I put these codes in the footer section of my site. Both to see the initial state of my site thoroughly and comfortably and to give general information about the site.
If you want something like this;
Bu kodları istediğiniz, uygun bir yere yerleştirebilirsiniz.
<!–?php $args=array( ‘orderby’ =–> ‘name’,
‘order’ => ‘ASC’
);
$categories=get_categories($args);
$cat_count = 0;
foreach($categories as $c) {
$cat_count++;
}
$count_posts = wp_count_posts();
$published = $count_posts->publish;
?>
Sitemizde<strong><!–?php echo $cat_count; ?–></strong> kategoride<strong><!–?php echo$published;?–></strong> adet yazı yazılmış ve<strong><!–?php echo $wpdb—>get_var(“SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = ‘1’”);?></strong> yorum bulunmaktadır.
It is that simple to show the total number of posts and comments on our site. See you in another post 🙂