Query posts from category based on a filter most favorited

I have one question. I need to query posts from category based on the filter most favorited ( http://pastie.org/2751114 ) which is placed in custom_sort.php to my index.php page

This is how the posts from categories are called ( http://pastie.org/2751131 ) in index.php.

Read More

Is there any way to get the posts from category based on the most favorited filter?

Thank You so very much in advance 😀

Related posts

Leave a Reply

1 comment

  1. query_posts accepts custom query variable as arguments. So assuming that adding

    ?sort_by=most_favourites
    

    to an url alters the sort order to sort by the most favourites (i.e. you’ve set sort_by as a recognised WordPress query variable, and setting it sorts the returned posts accordingly) then, try:

    $args = array(
        'cat' => $cat_lists[$i],
        'showposts' => intval(get_theme_option_by('bn_list_per_item', 6 )),
        'sort_by' => 'most_favourites',
        'post_type' => 'post');
    

    That should return the set number of posts from the category selected, in order of ‘most_favourites‘.

    Update:

    To alter the the value of sort_by for category with ID 30 (say), put the following, after $arg and before query_posts:

     if($cat_lists[$i]==30){
        $args['sort_by']='most_commented';
    }