Function not working on admin panel of custom post type

I am using the code below to add a column to my admin panel. The code works fine to show the page views from my posts. The problem is that it does not show the number of views of my custom post type on my admin panel. I know it is counting correctly because I looked into post meta.

// Add to a column in WP-Admin
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’] = __(‘Views’);
return $defaults;
}
function posts_custom_column_views($column_name, $id){
if($column_name === ‘post_views’){
echo wpb_get_post_views(get_the_ID());
}
}

Read more here:: Function not working on admin panel of custom post type

Leave a Reply

Your email address will not be published. Required fields are marked *