It’s fairly simple to add it manually for your categories, If you want to be able to set and store the sort order from the admin UI, that’s a bit more involved.
a manual fix can be achieved with a pre_get_posts hook:
function wpa55535_pre_get_posts( $query ){
// if this is a category page
if( $query->is_category ):
// if cat = 1, set order to ASC
if( $query->query_vars['cat'] == 1 ):
$query->set( 'order', 'ASC' );
// if cat = 2, set order to DESC
elseif( $query->query_vars['cat'] == 2 ):
$query->set( 'order', 'DESC' );
endif;
endif;
return $query;
}
add_action( 'pre_get_posts', 'wpa55535_pre_get_posts' );
If you’re using ‘pretty’ permalinks you’ll have to check for category_name instead of cat, as it’s queried by name not ID in that case.
Related Posts:
- Different post sort order within different categories
- How to sort posts by last name (2nd word) on ONE category only?
- How to sort posts alphabetically based on a specific parent category
- How to Change Order of Posts in Admin?
- Setting Custom Sort Order of Posts within a Category
- Query posts from current year
- Display posts in alphabetical order for a particular category
- How to sort posts inside categories
- how to get post order by post id wp_query?
- Sort by last word in title
- How to list post as buch of category, and all of them
- Sort Posts Alphabetically Based on Specific Category (Divi)
- How to display related posts from same category?
- How to show related posts by category
- Display all posts from specific categories on a page
- How do I reorder (pop and push) items from WP_Query?
- How to put last edited entry on top of the blog-post list?
- How to disable Uncategorized category URL?
- Add role that restricts user to post in specific category
- Group Posts by First Letter of Title
- Count posts in category including child categories
- Reverse chronology of post listing
- How can I custom order the results from wp_list_categories?
- Show Custom Taxonomy Categories, Listing of Posts, and Single Post via AJAX
- Order Posts by Alphabetical for Each Letter
- Archived Posts in Wrong Category
- Post in Multiple Categories to stay in current category (permalink, next previous post link)
- get_post_type_archive_link(‘post’) returns current category archive
- Get user’s most published categories
- Conditional that checks if a current category has any subcategory with posts
- How to set post expiration date and time and move the page to archive after expiration [closed]
- Exclude posts from featuring
- Server-side sorting of posts
- Articles are text-only in any “Category” instead of HTML
- How To Remove Certain category Posts From the Blog Page
- Add icon/badge next to posttitle of specific category
- Get current category id from post page wordpress
- WP_Query orderby not working with meta_value_num and menu_order
- Saving category to a post, before publishing the post
- Assign category to new post via URL
- Stop users posting into category while still seeing contents of the category
- Category Page Template not Showing Posts
- How to Restrict Previous & Next Post Link to Posts of Same Category?
- WordPress custom Query for Posts in Category display posts multiple times
- Categories list into registration form
- wp e-commerce group product by category [closed]
- How to make the first post in the loop be styled like a “new / featured” post?
- Order posts alphabetically: how to set order=asc in mysql query?
- How can you display all sibling categories to a post?
- Sort Custom Post Type by Category ID then Post Name
- Category page when using static front page
- How to create a “latest news” page showing a list of posts from blog category
- how to hide empty fields of post category description?
- Post filtering is returning blank page
- How to have more than one page for your posts if you have 8 posts but can store max 4 on a page
- Extract wordpress posts content and category content
- All categories displays the same posts
- Having pages after specifying post_type post
- Get latest post from categories
- How to show a featured image inside a post in only 1 single category
- Order posts by date
- Highlighting Current Category in the Archive and Feeds page
- Get current taxonomy and display query accordingly
- Geting error in post and category [closed]
- Display most recent posts in category with Twenty Ten theme widget
- Display a specific category in a focused area of my site
- Does having category name in permalinks affect SEO when having a post in multiple categories?
- query posts with selected post ids first
- How to 301 redirect from url with post id to permalink with post name (slug)?
- Create/Set Category as Title of Post
- How to display related post from same category in single.php
- Save All Post Permalink From A Specific Category into a .txt file
- show image gallery in archives or category page
- Page with Category Returning 1
- get current index of post content in category page
- Get 5 most recent categories
- Dynamically load posts based on category
- Get Categories & Posts With Type Article
- Allow reader to reorder posts for themselves (oldest first)
- Set multi posts random categories and tags
- Add new post only in assigned category
- Changing the Category for all posts of an Author
- Admin Post List Only Show One Category
- Add category attribute to custom recent post shortcode
- Same sidebar in all posts as in the category
- How do I list categories and the common categories for posts beneath those categories?
- Latest Posts not in the right order
- Retrieve latest post by multiple categories with ID
- How to Include a common category in a custom Category Search
- How to display only one post on first category page and rest on next pages?
- Last three posts not being put in order by date. How to fix this?
- Viewing category won’t show up Custom post type posts
- custom sort posts in archive/taxanomy page
- Show Title/Date/Excerpt of first post & only Title for rest in Query [duplicate]
- Listing category and its posts one by one
- Print out one of 2 post category [closed]
- How to get if category has posts?
- Show some texts in posts belonging to Specific category
- I have a website issue I am trying to resolve
- Category and archive issue