WordPress.org

Ready to get started?Download WordPress

Forums

How to order the posts by view count only for category pages (4 posts)

  1. Mixia
    Member
    Posted 1 year ago #

    Hi, I hope somebody would be kind enough to help.
    I currently have the home page that orders all of the posts by most recent date. I want to change the loop to order the posts by view count only for the category pages, while the order by most recet page in the Home Page don't have to change.
    I hope I've been clear, my enghish is a little rusty.

    Thanks so much for the help!

  2. simple1
    Member
    Posted 1 year ago #

    Try this...

    Install the WP-PostViews plugin http://wordpress.org/extend/plugins/wp-postviews/

    Then incorporate this code into your theme's Category template:

    <?php if (function_exists('get_most_viewed_category') && intval(get_query_var("cat")) > 0): ?>
    <ul>
    <?php get_most_viewed_category(get_query_var("cat"),'both',10); ?>
    </ul>
    <?php endif; ?>

    according to this thread http://wordpress.org/support/topic/get-query?replies=8

    When you view a category page you should see the posts within that category listed by most views in descending order.

  3. Mixia
    Member
    Posted 1 year ago #

    Many thanks for your answer!
    i will try and bring you up to date

    Bye

  4. Mixia
    Member
    Posted 1 year ago #

    Hi Simple1,
    I tried that, but unfortunately it returns N/A.
    It happened to other users too according to this thread http://wordpress.org/support/topic/get-query?replies=8

    Any suggestions?

    Thank you so much

    ps: In the Display Options of the WP-PostViews plugin I set the view counts should display juest for Single Post.
    This may cause any problems?

Topic Closed

This topic has been closed to new replies.

About this Topic