• Hi there, plugins works fine but now my client wants to sort posts on visits in descending order on landing page.

    so I need to do something like,

    ‘order’ => ‘desc’,
    ‘orderby’ => ‘KEY TO ADD HERE’

    please help me with this

    Thank you in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Meet Shah

    (@meet1347)

    I am waiting for a reply from 48 hours, will I get my answer ???

    Plugin Author Ajay

    (@ajay)

    Hi Meet, I monitor the forums as regularly as feasible and it might be weekly at times.

    I’m a bit confused by the question. The posts displayed by Top 10 should be in descending order by views by default.

    Alternatively, you might want to see how the API works: https://gist.github.com/ajaydsouza/c8defd4b46e53240e376

    Top 10 doesn’t save the counts in the meta, but in a separate table.

    • This reply was modified 8 years, 3 months ago by Ajay.
    Thread Starter Meet Shah

    (@meet1347)

    Hey Ajay, thanks for the reply.

    Let me make my requirement clear.

    I do have 3500+ portfolio posts and I am using this plugin to record daily visits. I am showing posts according to categories in different page. Now my client wants me to show most popular posts in the top for a particular category. I am managing the page through WP_Query so I can manage them but I don’t know which key should I pass in query to sort it.

    so,

    $args = array(
    ‘post_type’ => ‘portfolio’,
    ‘post_status’ => ‘publish’,
    ‘order’=>’desc’,
    ‘orderby’=>”what should I write here”,
    ‘posts_per_page’ =>-1
    );
    $new_query = new WP_Query( $args );

    I need to sort posts according to its visits, so the post with maximum post suppose to be in the top and the least one in the bottom.

    I hope my requirement is clear to you now.
    Have a good day ??

    Plugin Author Ajay

    (@ajay)

    Yes, you don’t have a meta key, you need to use the API as per my post above with the 'post__in' argument for WP_Query

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sort posts on the Total Views’ is closed to new replies.