• Resolved Robert DeVore

    (@deviodigital)


    I’ve been trying to get the helper function to display popular posts that have been PUBLISHED in the last 30 days, instead of counting views from ALL POSTS published.

    Is it possible to limit the popularity to only display popular posts published in the last 30 days?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @deviodigital,

    Assuming that by “helper function” you mean the wpp_get_mostpopular() function then yes, it’s possible. To limit popular posts to those published within the last 30 days you have access to the freshness parameter (see Settings > WordPress Popular Posts > Parameters):

    Parameter: freshness

    What it does: Tells WordPress Popular Posts to retrieve the most popular entries published within the time range specified by you

    Possible values: 1 (true), 0 (false)

    Defaults to: 1 (true), 0 (false)

    Here’s an example:

    <?php
    $args = array(
        'range' => 'last30days',
        'freshness' => 1
    );
    wpp_get_mostpopular($args);
    ?>

    P.S.: Yeah, I know that the parameter’s name isn’t the most intuitive but I really can’t find a better, memorable alternative that’s not longer than the current name haha. I’m open to suggestions if you have any!

    Thread Starter Robert DeVore

    (@deviodigital)

    That worked perfectly, thank you!

    I don’t know of a better name for it offhand, but if I think of one I’ll pass it along.

    Maybe a FAQ for this question could help? Or maybe there is one that I just overlooked? haha

    Plugin Author Hector Cabrera

    (@hcabrera)

    Well, only a handful of people has asked this specific question to be honest (probably need to reword / rephrase the thing as people might not know the feature even exists? haha) but yeah maybe it’s a good idea to write a FAQ about it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Is it possible to show popular posts PUBLISHED in the last30days?’ is closed to new replies.