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';
}
Related Posts:
- Change Default Content when Creating a Post based on Previous Category Choice
- Get rid of WordPress category, tag and author archives?
- How to add the category ID to admin page
- ajax category filter
- Filter categories using tags
- Make parent categories not selectable
- Add body class of category parent
- How to create a widgetized sidebar for every category dynamically?
- Only show category to certain user levels without plugin
- List Categories of the Parent Category of the Current Category
- Add custom category name as data-filter to switch between these categories
- exclude category from WordPress Form function
- wp_list_categories, Add class to all list items with children
- Remove “Parent” Selection When Adding/Editing Categories?
- Check is category parent or not from its ID
- Can paginate_links() be customized for a specific category or tag?
- Filtering by Category doesnt paginate correctly on the backend
- Manipulate Output of wp_list_something: select menu instead of li’s
- How can I get an tag to wrap each ancestor that gets outputted in this condition?
- Make parent category not selectable when it has child categories
- If category is in parent category?
- Replace category titles
- Hide posts of a certain category unless logged in
- If in category to be inside of a function
- What’s the Simplest Way to Override/Rewrite the %category% Permalink Structure Tag?
- Rename Default Category (Uncategorized) Via a Function
- How to Filter categories in the permalink structure
- How to display posts under a specific subcategory of a given category
- Taxonomy filter all children
- Filter Home Page Posts in Buddypress [closed]
- Check child/parent categories if exists
- Categorising posts/pages into years published
- Inserting Category programmatically
- Getting URL of archive (category) page
- Automatically set default password to all posts in a specific category
- How to show only one category in breadcrumb navigation
- get_the_categories filter returns an empty array
- category filter doesn’t work in WPML
- Filter Categories in meta box for CPTs
- Show only first category name in RSS?
- How to organize custom categories for filtering and selecting
- Filter $cpt categories to omit certain category
- How to set a filter by category within a customised page
- Refine/Filter the Search Results by Category
- Admin comments and user restrictions
- WordPress Post # of # filtered by category slug
- ajax for filtering posts by category in wordpress loops
- How to hide category name
- Add tag parameter to category.php
- Redirect to another page using contact form 7? [closed]
- Random Featured Image Based on Category
- Setting a default text for excerpts of a particular category
- How to make the ‘delete’ button inactive on some categories?
- add slug beside name in Admin Category Checklists
- Change div background acording to the selected category
- Overriding default calendar to show posts from a category
- How can I display tags as categories?
- Display all product tags associated with a specific product category
- Filter WooCommerce archive pages by an additional category
- Portfolio Filter Buttons Wont Work
- “Virtual category page” based on a custom field filter
- Custom tax_query filter not working for Woocommerce product categories
- How to hide some categories in dashboard
- How to use wp_list_categories with plugin category?
- How can I filter posts by tag on the fly
- Redirect depending on category chosen
- How to add icon over specific thumb
- How to add a custom thumbnail size for a specific category?
- create function to call category name and slug
- Different size video display for category page (smaller) & detail page (larger)
- Exclude posts without category from loop
- How to fix select filter on category
- wp_dropdown_categories() works correctly but the list is not filtered in admin for custom post type. What is the problem?
- Add $args to wp_list_categories
- How to hide a category or tag everywhere EXCEPT for use with get_posts
- Add filter for specific category only
- How to create category filter on a blog like on the site below?
- How to filter tags by category?
- Custom Taxonomy Isotope Grid – Filter Buttons Not Working
- How to exclude a category returned by get_categories from function.php?
- Can’t display posts by filtering categories using isotope.js
- Correct Hook/Filter to amend category choices on post edit page
- Restrict retrieved terms by category?
- Graphic before title – Specific Category
- Remove “Category:”
- ACF Gallery with Media Categories – how do display categories and sort
- Code to display category-specific single.php is overriding normal single.php, too
- Custom filters inside a specific category?
- Loop Through Categories in Custom Field
- filter single_cat_title avoiding the breadcrumbs
- Function to list posts from current post’s category fails in WP 3.8
- Right way for setting categories
- Custom built theme won’t filter categories
- Show only one category in main query, issues on tag page
- How to Insert A List of Posts in A Category Written by the Author into the Author Archive
- category filter doesn’t work
- Show parent-child relationship for categories in the wordpress admin
- How to create a photo gallery that can be filtered by the image categories
- Replace category titles inside RSS feed
- Filters do not work when there are multiple (one works)