Support » Plugin: WP Document Revisions » [Plugin: WP Document Revisions] Get most viewed documents?

Viewing 4 replies - 1 through 4 (of 4 total)
  • … just tried wp-postviews, but it doesn’t count the document downloads. Anyone any ideas where to start? Thank you!

    Plugin Author Ben Balter

    (@benbalter)

    If you have any caching, this would be impossible.

    You could hook into the serve_document hook, and create this functionality, but nothing exists out of the box.

    If you do make this work, I would love to add the code to the plugin’s code cookbook.

    I’ve sent you the code via e-mail.

    Here’s the code that makes WP Document Revisions work together with wp-postviews.

    Into functions.php:

    add_action( 'serve_document', 'update_document_views');
    function update_document_views($post_id) {
    $post_views = intval(get_post_meta($post_id, 'views', true));
    if ($post_views) update_post_meta($post_id, 'views', ($post_views+1));
    else add_post_meta($post_id, 'views', 1, true);
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: WP Document Revisions] Get most viewed documents?’ is closed to new replies.