WordPress Yazı, Yorum, Kullanıcı Sayısını Gösterme

WordPress’te eklentisiz bir şekilde; sitede kaç adet yazı, yorum ve kullanıcı olduğunu kolay bir şekilde gösterebilirsiniz.
Aşağıdaki kodları kullandığınız temanın functions.php dosyasının en alt satırına ekleyiniz.
function my_total_posts() {
$total = wp_count_posts()->publish;
return $total;
}
add_shortcode('total_posts','my_total_posts');
function wpb_comment_count() {
$comments_count = wp_count_comments();
$message = ''. $comments_count->approved . '';
return $message;
}
add_shortcode('wpb_total_comments','wpb_comment_count');
// Function to return user count
function wpb_user_count() {
$usercount = count_users();
$result = $usercount['total_users'];
return $result;
}
// Creating a shortcode to display user count
add_shortcode('user_count', 'wpb_user_count');
Daha sonra aşağıdaki kodları istediğiniz bir yere HTML bileşeni olarak ekleyebilirsiniz.
Yazı Sayısı: <strong>[total_posts]</strong>
<br>
Üye Sayısı: <strong>[user_count]</strong>
<br>
Yorum Sayısı: <strong>[wpb_total_comments]</strong>