View Single Post
Old 08-10-2015, 06:38 PM  
Miguel T
♦ Web Developer ♦
 
Miguel T's Avatar
 
Industry Role:
Join Date: May 2005
Location: Full-Stack Developer
Posts: 12,472
I already did something like that, since I'm using "Wp-PostViews", I can easily sort out the post based on the "Views".

For example...

http : // www . mysite . com /some-category-name/?sort=views

And then I changed the WP Query in the archive/category to:
Code:
if(isset($_GET['sort'])) { $_SESSION['sort'] = $_GET['sort']; }
if($sort == 'views') {
   query_posts($query_string.'&v_sortby=views&v_orderby=desc&posts_per_page=24');
} else {
   //do the regular query here...
}
The code above was adapted for this GFY Post Obviously you should sanitize all GET inputs, etc.
__________________

Full Stack Webdeveloper: HTML5/CSS3, jQuery, AJAX, ElevatedX, NATS, MechBunny, Wordpress
Miguel T is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote