Query posts from category based on a filter most favorited

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';
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)