Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Set post views count using post meta

/*
 * Set post views count using post meta
 */
function setPostViews($postID) {
    $countKey = 'post_views_count';
    $count = get_post_meta($postID, $countKey, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $countKey);
        add_post_meta($postID, $countKey, '0');
    }else{
        $count++;
        update_post_meta($postID, $countKey, $count);
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: execute query and use die in php 
Php :: php string concat 
Php :: apagar windows desde consola 
Php :: ph form 
Php :: eager load relationships on an existing model in route laravel 
Php :: array value auto fill in old value laravel 8 
Php :: Dorf SMS Plugin 
Php :: carbon in laravel documentation 
Php :: 2.30 will display 2.3 in php 
Php :: laravel 8 storing dynamic checkbox integer value array 
Php :: How to Create a Transient PHP wordpress 
Php :: what is WP_USE_THEMES 
Php :: mail php send 
Php :: The requested URL was not found on this server. Apache/2.4.47 (Win64) OpenSSL/1.1.1k PHP/7.3.28 Server at localhost Port 80 error in laravel 
Php :: 150 charachter display only php 
Php :: fichier wp-config.php 
Php :: how to show limited text in laravel on page 
Php :: Laravel: validate an integer field that needs to be greater than another 
Php :: Binance api buymarket php 
Php :: php random number routing 
Php :: generateThumbnailRepresentations 
Php :: api newslater with php 
Php :: how to keep some value on input field 
Php :: laravel gigapay resend invite to employee 
Php :: how do istart writing a php code 
Php :: image downlord 
Php :: enfold remove debugging info for theme support 
Php :: Target class [LoginController] does not exist. 
Php :: current date time in php for input 
Php :: random String Function PHP 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =