WordPress.org

Ready to get started?Download WordPress

Forums

WP Document Revisions
[resolved] Get most viewed documents? (5 posts)

  1. Christoph
    Member
    Posted 2 years ago #

    Is there a way to sort by the most viewed documents or display a download counter for each document? If documents are really posts, plugins like wp-postviews could work?
    Thanks!

    http://wordpress.org/extend/plugins/wp-document-revisions/

  2. Christoph
    Member
    Posted 2 years ago #

    ... just tried wp-postviews, but it doesn't count the document downloads. Anyone any ideas where to start? Thank you!

  3. Ben Balter
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  4. Christoph
    Member
    Posted 1 year ago #

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

  5. Christoph
    Member
    Posted 1 year ago #

    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);
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.