Jump to content
Sign in to follow this  
Jean-Philippe

How to display the number of views in the post byline information with WP-PostViews plugin?

Recommended Posts

Jean-Philippe

Hey! I would like to display the number of views in the post byline information thanks to WP-PostViews plugin. WP-PostViews user guide says: 1) Open wp-content/themes//index.php 2) You may place it in archive.php, single.php, post.php or page.php also. 3) Find: <?php while (have_posts()) : the_post(); ?> 4) Add Anywhere Below It (The Place You Want The Views To Show): <?php if(function_exists('the_views')) { the_views(); } ?> I understand I should use a "hook" but I don't know how to proceed. Can anyone tell me please? Thank you for your help. Jean-Philippe http://www.kankei.fr


www.photoreview.fr | www.kankei.fr

Share this post


Link to post
Share on other sites
Kate
If you just want to use it below the posts (as suggested in the steps above), you can modify template.postloop.php. But, it would be best to first copy it to your Base theme and activate that. ;) If you want to add it at the end of the byline, please check out these posts: http://www.pagelines.com/forum/discussion/comment/68348 http://www.pagelines.com/forum/search?Search=pagelines_get_post_metabar

Share this post


Link to post
Share on other sites
inov8ed
I went through this as I wanted to do exactly the same thing. I really didn't want to edit the php files directly and instead opted for a hook and filter. Here is the hook for getting the pageview count. Originally the code came from somewhere that wanted to only have it show when logged in: [code] function userfunc_get_post_views($postID, $display_to_all = false) { if ( $display_to_all || is_user_logged_in() ) { global $post_stats; foreach ( $post_stats as $p ) { if ( $p['post_id'] == $postID ) { ?>
()

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×