Wordpress orderby function

1 replies
Hi,

I'm using Post Ratings on one of my Wordpress sites and I want to give my visitors the possibility to sort the posts by rating. For that I'm using a $_GET function and this code:

PHP Code:
case 'rated' :    $orderby '&meta_key=rating&orderby=meta_value'
("rating" is a custom field)

The code works fine but I also want to sort the posts by number of votes so that a post that has a rating of 5 and 3 votes should be placed before a post that has a rating of 5 but only 1 vote. How can I do that?

/Woolwich
#function #orderby #wordpress
  • Profile picture of the author SteveJohnson
    You'll have to add the key and value for votes, then structure your query modification as an array.

    See this page: Class Reference/WP Query « WordPress Codex for details. Look for the "Multiple 'orderby' values" section.
    Signature

    The 2nd Amendment, 1789 - The Original Homeland Security.

    Gun control means never having to say, "I missed you."

    {{ DiscussionBoard.errors[5655705].message }}

Trending Topics