WordPress.org

Ready to get started?Download WordPress

Forums

How do I use query_post as a link to sort my posts? (7 posts)

  1. designinfantry
    Member
    Posted 4 years ago #

    How do I sort the posts upon click of links?

    Sort by: Latest | Most Popular | Score

    Most popular is by view count and is by custom field in DESC order.

  2. Jonas Grumby
    Member
    Posted 4 years ago #

    There are ways to display latest and most popular posts with widgets, but I don't know about "Score".

  3. jonradio
    Member
    Posted 4 years ago #

    There are also plug-ins that will do this, though I haven't any personal experience using them. I'd start with this search:
    http://wordpress.org/extend/plugins/search.php?q=sort+posts&sort=

  4. designinfantry
    Member
    Posted 4 years ago #

    I've exhausted the plugins list.

    The closest I've come to it WP Smart Sort, but it is very difficult to style the menu.

  5. jonradio
    Member
    Posted 4 years ago #

    Could you not have three templates to do this? That only differ by the query_post parameters used. And whether Latest, Most Popular or Score is highlighted after the "Sort by:". I'm assuming that default sort if Latest.

    Those three links (Latest, Most Popular, Score) would point to three otherwise identical pages, that only differ in what Page Template they are assigned to.

  6. jonradio
    Member
    Posted 4 years ago #

    Thinking about it more, I realized you could avoid the three templates by passing a parameter through the "Sort by:" URL you specify, e.g. - &sortby=latest

  7. Mark / t31os
    Moderator
    Posted 4 years ago #

    How do I sort the posts upon click of links?

    By using a conditionalised query variable that's passed into the query to determine which order they display in.

Topic Closed

This topic has been closed to new replies.

About this Topic