Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wp post view

    function bac_PostViews($post_ID) {

    $count_key = 'post_views_count';
    $count = get_post_meta($post_ID, $count_key, true);

    if($count == ''){
        $count = 0;
        delete_post_meta($post_ID, $count_key);
        add_post_meta($post_ID, $count_key, '0');
        return $count . ' Visitas';

    }else{
        $count++; 
        update_post_meta($post_ID, $count_key, $count);

        if($count == '1'){
        return $count . ' Visita';
        }
        else {
        return $count . ' Visitas';
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: delete a migration laravel 
Php :: download image from mysql using php 
Php :: find the next 7 date data in laravel eloquent 
Php :: generate a unique id 
Php :: httpclient add authorization header symphony 
Php :: laravel delete method 
Php :: php pass function as callback 
Php :: iqbal Laravel save record in two table in one line 
Php :: wherebetween laravel 
Php :: php unit test 
Php :: chunk_split (PHP 4, PHP 5, PHP 7, PHP 8) chunk_split — Split a string into smaller chunks 
Php :: laravel set timezone dynamically 
Php :: how to use concat in laravel 
Php :: php password_hash 
Php :: show date php by letters 
Php :: PHP parse_str — Parses the string into variables 
Php :: how to make primary key and foreign key in phpmyadmin 
Php :: yii2 oauth2 
Php :: how to separate admin and user login in laravel 
Php :: public $baseURL codeigniter 4 
Php :: dont insert duplicate data in laravel 
Php :: get data in php 
Php :: if one condition 
Php :: share to facebook from website laravel 
Php :: check if a string contains a word 
Php :: laravel debugbar ServiceProvider to the providers 
Php :: contractors php 
Php :: formidableforms limit only 2 submissions per user 
Php :: laravel dynamically add remove table row 
Php :: en php comment convertir une date en français stackoverflow 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =