WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Popular Posts
[resolved] [Plugin: WordPress Popular Posts] Template query for most viewed of last week post (3 posts)

  1. oomskaap
    Member
    Posted 2 years ago #

    I currently use this code to get the WP-Post views plugin's views, but it does not support a date. So i want to transfer over to this plugin and include a date of last week.

    <?php
    $cat_id='-8';//the category ID
    $limit = get_option('posts_per_page');
    
    query_posts(array('category__and'=>array(276),
    'showposts'=>8,'more' => $more = 0,
    'meta_key' => 'views',
    'orderby' => 'meta_value_num',
    'order' => 'DESC',
    ));
    ?>

    How, and where and what do i have to put in the above code for it to work?

    Thanks!

    http://wordpress.org/extend/plugins/wordpress-popular-posts/

  2. H├ęctor Cabrera
    Member
    Plugin Author

    Posted 2 years ago #

    Hi oomskaap,

    WordPress Popular Posts has its own template tag called wpp_get_mostpopular() that you can use to get the most viewed posts from last 7 days (please note I said days, and not week).

    Here's an example:

    <?php
    if (function_exists( 'wpp_get_mostpopular' )) {
      wpp_get_mostpopular('range=weekly&cat=276&order_by=views&limit=8');
    }
    ?>

    That code would get the most viewed posts belonging to the category 276 (as seen at your code) from the past 7 days.

  3. oomskaap
    Member
    Posted 2 years ago #

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.