wp post view

Solutions on MaxInterview for wp post view by the best coders in the world

showing results for - "wp post view"
Katara
06 Jun 2019
1    function bac_PostViews($post_ID) {
2
3    $count_key = 'post_views_count';
4    $count = get_post_meta($post_ID, $count_key, true);
5
6    if($count == ''){
7        $count = 0;
8        delete_post_meta($post_ID, $count_key);
9        add_post_meta($post_ID, $count_key, '0');
10        return $count . ' Visitas';
11
12    }else{
13        $count++; 
14        update_post_meta($post_ID, $count_key, $count);
15
16        if($count == '1'){
17        return $count . ' Visita';
18        }
19        else {
20        return $count . ' Visitas';
21        }
22    }
23}
24
similar questions
queries leading to this page
wp post view