WordPress.org

Ready to get started?Download WordPress

Forums

WP-PostRatings
[resolved] 'Get highest rated range' issue (5 posts)

  1. jardokraka
    Member
    Posted 7 months ago #

    What I am trying to achieve is list 10 highest rated posts from the last, say, 30 days.

    According to the FAQ, I should use

    <?php get_highest_rated_range('30 days', 'post', 10); ?>

    The issue is with the range — the plugin lists the posts (seemingly) based on the date when they were rated (rating timestamp?), while I need the criteria to be the post date.

    If at all possible, I would also like to further limit the selection to a minimum of, say, 5 votes.

    Any help would be greatly appreciated.

    http://wordpress.org/plugins/wp-postratings/

  2. Lester Chan
    Member
    Plugin Author

    Posted 7 months ago #

    That feature is not in the plugin and even using WordPress query_post() you will not be able to get Last X Days of post.

    You basically have to write your own query to archive that.

    I would recommend checking out get_highest_rated() function in postratings-stats.php and perhaps adding a $wpdb->posts.post_date >= ( CURDATE() - INTERVAL 5 DAY ) to the end of the query.

  3. jardokraka
    Member
    Posted 7 months ago #

    Thank you very much for your help, I was able to achieve what I wanted.

    Is there a way I could preserve the newly created function somehow? For now I added it directly to postratings-stats.php, but this file will be overwritten when the plugin is updated.

  4. Lester Chan
    Member
    Plugin Author

    Posted 7 months ago #

    You can put it in your theme's functions.php if there is one, if not you can create the file and put the function there

  5. jardokraka
    Member
    Posted 7 months ago #

    Excellent. I had thought about adding the function to functions.txt, just wanted to make sure first it was the right thing to do. Again, thank you for your help, I will probably come back in a few days with more questions :)

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.