• Resolved SchweizerSchoggi

    (@schweizerschoggi)


    Another question from my side…

    I would like to display the 5 most popular posts in a content slider. I am using “Slide Anything” for this and it allows shortcodes to be integrated as slider content.

    So my question is:
    is there an option to have a shortcode for the overall most popular post on my page, the second most popular post and so on? Instead of having one shortcode to identify and display the top 5 at once.

    Do you understand what I want to achieve?

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

    (@hcabrera)

    Yeah, I think I do see what you’re trying to do. One way to achieve that with Slide Anything is using the [wpp] shortcode (as you’re already doing) in conjunction with two parameters:

    • limit, so the shortcode displays only one popular post.
    • offset, an undocumented parameter that allows you to skip N number of posts.

    For example:

    • [wpp range='all' limit=1] will display only the top popular post,
    • [wpp range='all' offset=1 limit=1] will display the second most popular post,
    • [wpp range='all' offset=2 limit=1] will display the third most popular post,
    • etc.

    Here offset works exactly as MySQL’s OFFSET (see SELECT statement for more).

    Note though that because the popular posts list is dynamic (can and will update frequently as users interact with your website) using the shortcode like this with Slide Anything might return unexpected results sometimes. Personally I’d rather convert the popular posts list itself into an actual slider (like this for example: How to create a simple image slider with jQuery) to make sure the result is consistent all the time.

    Thread Starter SchweizerSchoggi

    (@schweizerschoggi)

    Overall that’s a nice solution.
    Meanwhile I’ve tested it in action and experienced some other problems with the “Slide Anything” plugin. I will go with a handmade solution now in combination with your shortcodes above.

    Super helpful again, thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcode to get 1st, 2nd, 3rd most popular post’ is closed to new replies.