You can change the sort order on a category archive page to show posts by title (A-Z) by adding this code to your child theme’s functions.php:
/* Sort posts by title for a specific category */
function change_category_order( $query ) {
//Sort all posts from category with id=3 by title
if($query->is_category('3') && $query->is_main_query()){
$query->query_vars['orderby'] = 'name';
$query->query_vars['order'] = 'DESC';
}
}
add_action( 'pre_get_posts', 'change_category_order' );
You need to replace “3” with the correct category id. You can find out the category id by heading to dashboard => post => categories and hover over the category you want to adjust the sort order.
Related Posts:
- Redirect to another page using contact form 7? [closed]
- Why is this custom taxonomy showing in the database?
- plugin for wp_list_categories with posts
- How to add rewrite rules and pagination to retrieve attachments files?
- Show Heirachy of categories in WP Download Monitor
- Possible to replicate economist.com’s debate section in wordpress? [closed]
- My Category is too big on the Menu what can i do?
- WordPress category add image field
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- polylang + category/tag custom language link
- How do I apply style to each category of a list?
- .php file for woocommerce edit category? [closed]
- Renaming Custom Taxonomy Values
- How to hide featured images of all posts falling under the same category in wordpress?
- Adding category base to url in custom post giving 404?
- Precheck fields when I add a new post
- Add custom WordPress admin page with pretty url via code
- Cannot view Custom Post Type no matter what I try
- Create survey that redirects to sidebar menu customized to answers
- Taxonomy Category Icon on index page
- Sub Categories in drop down menu
- How can I pass value to function in add_menu_page?
- Category archive in menu
- How can I add the custom taxonomy categories to the posts and pages?
- Make a Custom template for a specific category in wordpress
- How to pre-set WordPress settings for specific posts?
- How to make horizontal scrolling menu [closed]
- Difference between add_filter and apply_filters
- How to delete the Hello Dolly plugin automatically?
- Combine two taxonomies in a hierarchical tree
- Show Similar Post Titles ( Similar to Stack Exchange )
- How do I unlock a post programmatically?
- Open external links in a new window
- Custom wp_nav_menu output (displaying all child elements of top menu element in current branch)
- How to add usermeta to “Notice of Email Change” email message
- How to display a category list in a mediawiki like way?
- WordPress 3.1 and Disqus throws Warning: number_format() error in Posts List
- Order Taxonomy Term by date created
- How can I rewrite a plugin generated URL?
- Leveraging WordPress Comments on Custom Plugin Object page
- Debugging Technique Question re: functions.php
- Is there a way to alter the order in which the plugins appear in the page?
- How to check what plugins used to be on a WordPress installation?
- Weird problem happening with custom taxonmy when creating/updating posts
- FacetWP group listings by custom field [closed]
- Display content from custom post type if match to main post category
- Menus, but not by theme location
- WordPress plugin – Error “Plugin generate 2890 characters of unexpected output when activated”
- Remove Duplicator plugin from admin menu if not an administrator
- Add a custom form on the post-new.php admin page
- Edit Yoast SEO breadcrumbs output [closed]
- Trouble with editing template for “List category posts” plugin
- className not populating in custom block
- In the archive widget, how do I sort in between two years?
- Customization API for plugin development
- Fromcraft Plugin On click submit button [closed]
- creating a custom shop page display on archive woocommerce
- Center and hide overflow of WP toolbar custom links
- Creating Featured Content Boxes
- How to set category correctly for a custom post created by a remote API call?
- Moving FB comments at the end of page
- Customizing a blog page layout
- How to add category and subcategory in WordPress custom code?
- Hook on creating a menu entry?
- How to handle a WordPress blog with articles in different languages?
- Call javascript functions from each page
- navigation among single posts
- Link Posts to External URL
- how to create hierachial taxonomy and manage under single post type?
- Button and Countdown overlapping mobile menu
- Check if theme supports sidebar
- Custom Post Type same name as Category
- Mobile Menu and Mobile Sidebar missing
- Adding discount functionality to the cart
- Changing the CSS with a plugin
- automatically set random featured image by category in wordpress on post
- Custom wp_list_tables redirect on specfic page
- Circular Menu to show on pages
- Paid Membership Pro displaying a user name in PHP
- Automatically check “Enable stock management at product level” to the existing products?
- Get only selected custom taxonomy
- Creating Nested custom fields
- Adding icons next to categories in wp_nav_menu
- How to add a post with new Taxonomy without assigning to default category?
- Plugin does not create a custom table upon activation
- Disable default posts (Posts,Pages,Comments and Media) in wp-admin
- Plugin program: JQuery not working in this plugin
- Show similar category portfolio items?
- How to create default categories in new installs?
- Plugins for putting Custom Post Types into the Menu
- Find And Add Category to Posts
- admin panel save option with ajax
- 404 not found problem with URL rewrite custom category
- ACF Taxonomy Object term Null [closed]
- Social network plugins for WordPress [closed]
- Why haven’t I see plugins using get_file_data to handle retrieving plugin version?
- Wrapping code in an if block
- Create Custom Coupon Type
- How does one add numbers to an admin menu?
- Adding fontAwesome to Primary Menu returns after saving the menu