One additional usefull function (2 posts)

  1. dawid-urbanski
    Posted 2 years ago #


    First: great plugin, very simple but usefull.

    I wrote a little additional function to this plugin. I've noticed that if i want to show posts views on main page (or anywhere except single.php) that incerase view property even if no one see the article. So I've decided to add function echo_post_views_not_counted() with is not adding view info to db. Now on every page I use this function, and on page single.php im using normal echo_post_views(). Maybe for someone it will be usefull.

    Paste the following function in wp-post-view.php file, below echo_post_views() function (in my case 19.03.2013 - ver 1.0) its 125 line).

    if (!function_exists('echo_post_views_not_counted')) {
         * Echo, print or display the views of the post.
         * @param <type> $post_id
        function echo_post_views_not_counted($post_id) {
            if ($post_id) {
                $views = wp_get_post_views($post_id);
                echo number_format_i18n($views);
            } else {
                echo 0;

    Use simply like other functions:

    <?php echo_post_views_not_counted($post->ID); ?>
    <?php echo_post_views_not_counted(get_the_ID()); ?>


  2. Cheolguso
    Posted 2 years ago #

    Thank you very much.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP-post-view
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic