• Resolved akademiatortu

    (@akademiatortu)


    Hi-
    I’d like to show top 3 most viewed posts in the last 24hours on my page. I’d like to build a section where I would have the top 3 with a little plaque above each post with the number place the post received. So we’d have number 1, 2, 3, as in 1st, 2nd and 3rd place. How can I get that info to display on the page – how can I sort the view in this way? Can I query it where I would get only the top 3 posts to show?

    Thank you.

    Also, is it possible to add pagination to the view?

    The page I need help with: [log in to see the link]

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

    (@hcabrera)

    Hi @akademiatortu,

    How can I get that info to display on the page – how can I sort the view in this way?

    For this kind of thing I’d use the wpp_get_mostpopular() template tag to retrieve the most viewed posts from the last 24 hours, like so for example:

    <?php
    if ( function_exists('wpp_get_mostpopular') ) {
        /* Get up to the top 5 commented posts from the last 7 days */
        wpp_get_mostpopular(array(
            'limit' => 3,
            'range' => 'last24hours'
        ));
    }
    ?>

    Note that the above code will display a very simple list of popular posts. I assume you want your popular posts list to look like the posts grid you have on that page, if so then maybe this can help: How can I style my list to look like [insert your desired look here]?

    Also, is it possible to add pagination to the view?

    Someone else asked this exact same question recently, have a look here: Pagination of posts?

    Thread Starter akademiatortu

    (@akademiatortu)

    Is it possible to show only the top one.
    Is it possible to show only the second most popular, or third most popular – within the last 24h?

    Plugin Author Hector Cabrera

    (@hcabrera)

    Yep, if you use that function then you get access to the offset parameter as described in the Parameters documentation (Settings > WordPress Popular Posts > Parameters) and in the link I shared earlier ??

    Update: I’ll correct myself, the offset parameter is not documented in the Parameters documentation (it’s not there on purpose, I just forgot about that).

    Thread Starter akademiatortu

    (@akademiatortu)

    Hector-
    Thank you for all the answers. I have one more question. I understand that the last 24h parameter is basically changing all the time. Is there a way to, per say” get a time stamp result. I’d like to be able to show the top 3 post from Monday, Tuesday etc. So I’d need a “time stamp” results from last 24h say at midnight of each day… Sorry, not sure if I’m making myself clear…

    Plugin Author Hector Cabrera

    (@hcabrera)

    No, that’s not possible. The plugin doesn’t offer such functionality. The views data is in the database though, if you’re familiar with PHP/MySQL (or know someone who is) then you certainly could get the most viewed post(s) from a specific day.

    Thread Starter akademiatortu

    (@akademiatortu)

    Got it. I see in the plugin dashboard, there is an option to see stats. However, even though the code work on the front end it does not show me any stats on the dashboard… why is that?
    https://cakeroom.pl/

    Plugin Author Hector Cabrera

    (@hcabrera)

    What do you mean?

    Thread Starter akademiatortu

    (@akademiatortu)

    Plugin Author Hector Cabrera

    (@hcabrera)

    So, it gets stuck on the loading animation? If so then please check your browser’s console and see if there are any errors being logged.

    Thread Starter akademiatortu

    (@akademiatortu)

    Yeah, same thing on 3 browsers: safari, Chrome and Firefox though…

    Plugin Author Hector Cabrera

    (@hcabrera)

    Did you check your browser’s console for errors?

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Ranking top posts’ is closed to new replies.