• 03-07-2022, 19:55:31
    #1
    Sayfa görüntülemesi kodum var, cache aktif olunca kod sadece 1 noktada kalıyor bunu nasıl aşabilirim bilgisi olan var mı?


     function getPostViews($postID){
         $count_key = 'post_views_count';
         $count = get_post_meta($postID, $count_key, true);
         if($count==''){
             delete_post_meta($postID, $count_key);
             add_post_meta($postID, $count_key, '0');
             return "0 View";
         }
         return $count.' View';
     }
     function setPostViews($postID) {
         $count_key = 'post_views_count';
         $count = get_post_meta($postID, $count_key, true);
         if($count==''){
             $count = 0;
             delete_post_meta($postID, $count_key);
             add_post_meta($postID, $count_key, '0');
         }else{
             $count++;
             update_post_meta($postID, $count_key, $count);
         }
     }
    
    
     add_filter('manage_posts_columns', 'posts_column_views');
     add_action('manage_posts_custom_column', 'posts_custom_column_views',5,2);
     function posts_column_views($defaults){
         $defaults['post_views'] = __('Görüntüleme Sayısı');
         return $defaults;
     }
     function posts_custom_column_views($column_name, $id){
      if($column_name === 'post_views'){
             echo getPostViews(get_the_ID());
         }
     }
  • 04-07-2022, 15:17:01
    #2
    Bu kodu ön bellekten hariç tutmalısınız yanılmıyorsam. Eklentiye göre exclude etmelisiniz.
  • 04-07-2022, 16:58:43
    #3
    Misafir adlı üyeden alıntı: mesajı görüntüle
    Bu kodu ön bellekten hariç tutmalısınız yanılmıyorsam. Eklentiye göre exclude etmelisiniz.
    İşe yaramıyor hariç buraktım ancak yine aynı şekilde çalışıyor.
  • 04-07-2022, 17:57:44
    #4
    fatihsyn adlı üyeden alıntı: mesajı görüntüle
    İşe yaramıyor hariç buraktım ancak yine aynı şekilde çalışıyor.
    Son olarak bir sıkıştırma, boyut küçültme işlemi yapan bir eklenti varsa bunlardan dolayı da olabilir.