• 03-07-2023, 03:44:35
    #1
    arayıp bulamayan vardır belki hoş bir görüntü oluşturuyor

    <?php
    function get_site_statistics() {
        global $wpdb;
    
        
        $total_posts = wp_count_posts()->publish;
    
        
        $total_users = count_users();
        $total_editors_admins = $total_users['avail_roles']['editor'] + $total_users['avail_roles']['administrator'];
    
        
        $total_images = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment'");
    
       
        $total_categories = wp_count_terms('category');
    
        
        $total_users_count = $total_users['total_users'];
    
        
        $statistics = array(
            'total_posts' => $total_posts,
            'total_editors_admins' => $total_editors_admins,
            'total_images' => $total_images,
            'total_categories' => $total_categories,
            'total_users_count' => $total_users_count
        );
    
        return $statistics;
    }
    
    
    $statistics = get_site_statistics();
    
    
    echo 'Toplam Konu: ' . $statistics['total_posts'] . '<br>';
    echo 'Toplam Editör ve Admin: ' . $statistics['total_editors_admins'] . '<br>';
    echo 'Toplam Resim Sayısı: ' . $statistics['total_images'] . '<br>';
    echo 'Toplam Kategori Sayısı: ' . $statistics['total_categories'] . '<br>';
    echo 'Toplam Kullanıcı Sayısı: ' . $statistics['total_users_count'];
    ?>
    • Berkt
    Berkt bunu beğendi.
    1 kişi bunu beğendi.
  • 04-07-2023, 09:44:51
    #2
    Sayfa her açılışında sorgu yapar bu kod. Bunu transient api ile önbelleğe alırsanız daha iyi olur. https://developer.wordpress.org/apis/transients/