WordPress.org

Support

Support » How-To and Troubleshooting » How do I use query_post as a link to sort my posts?

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

  • designinfantry
    Member

    @designinfantry

    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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • There are ways to display latest and most popular posts with widgets, but I don’t know about “Score”.

    jonradio
    Participant

    @adiant

    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=

    designinfantry
    Member

    @designinfantry

    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.

    jonradio
    Participant

    @adiant

    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.

    jonradio
    Participant

    @adiant

    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

    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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How do I use query_post as a link to sort my posts?’ is closed to new replies.