Post count view at dashboard WordPress not displaying
-
I’m making a post count at dashboard WordPress but it not is displaying.
I founded this tutorial:
This code display the count view for single.php
In my functions:
`function wpmidia_set_post_views($postID) {
$cookie = strtotime(date(‘Y-m-d’));
$pv_url = ‘wpmidia_’.md5($_SERVER[‘REQUEST_URI’]);if( is_single() && !isset($_COOKIE[$pv_url]) ){
$count_key = ‘_wpmidia_post_views_count’;
$count = get_post_meta($postID, $count_key, true);
if($count==”){
$count = 1;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, $count);setcookie($pv_url, $cookie, time()+3600, COOKIEPATH, COOKIE_DOMAIN, false); // 1h
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}}
}`In my single.php:
<?php echo wpmidia_get_post_views($post->ID); ?>
How I said this code display the count post in WordPress pages single, page or another.
This code show the count view at Dashboard. Exactly what I want to do. The “Views” field in the dashboard is created, however the counter does not work, nothing is displayed:
`add_filter(‘manage_posts_columns’, ‘wpmidia_posts_column_views’);
function wpmidia_posts_column_views($defaults){
$defaults[‘post_views’] = __(‘Views’);
return $defaults;
}add_action(‘manage_posts_custom_column’, ‘wpmidia_custom_column_views’,5,2);
function wpmidia_custom_column_views($column_name, $id){
if($column_name === ‘post_views’){
$count = get_post_meta($id, ‘_wpmidia_post_views_count’, true);
if( !empty($count) ){
echo $count. ‘ views’;
}
}
}`How can I solve this?
- The topic ‘Post count view at dashboard WordPress not displaying’ is closed to new replies.