Display post views within admin post columns
wordpress snippet
I posted a cool snippet yesterday to (track post views using post meta) I wanted to add a little to that today. Adding this snippet to the functions.php of your wordpress theme will display the post views next to each post in the wordpress admin.
snippet : PHPcopy
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 getPostViews(get_the_ID());
}
}
this months featured snippets
- http://www.facebook.com/konstantin.yelin Konstantin Yelin
- http://wpsnipp.com Kevin Chard
- http://www.facebook.com/konstantin.yelin Konstantin Yelin
- http://wpsnipp.com Kevin Chard
- Xwtiko
- Anonymous
- http://twitter.com/shakirul007 Shakil Ahmed











