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]
- How can I keep a WordPress dropdown menu open when navigating to a child page?
- custom taxonomy and custom post type url conflict
- WordPress and WebRTC?
- Will Flutter work with WordPress 3.0?
- Making menu link open in new tab?
- Leveraging WordPress Comments on Custom Plugin Object page
- Copyright messages for a particular set of pages
- Debugging Technique Question re: functions.php
- Include Max mega menu Plugin into theme
- Check if User exists in WordPress Multisite
- How use %like% in sql statement wordpress
- Multiple menu items highlighted
- Is there a way to alter the order in which the plugins appear in the page?
- Getting Post details when post is published
- Override the filter from plugin in child theme
- force customers to add only single item to card per purchase EDD [closed]
- Preventing BFA in WordPress without using a plugin
- Custom plugins/Manipulated plugins: Always a terrible idea to inherit these types of WP sites that discourage updates? [closed]
- Delete Associated Media Upon Page / Post Deletion
- How to check what plugins used to be on a WordPress installation?
- wordpress.org codebase
- Custom Taxonomy Tag Search
- Output HTML only on individual post view
- Add custom taxonomy to title tag [closed]
- Can a plugin deactivate and delete itself once installed and activated?
- Weird problem happening with custom taxonmy when creating/updating posts
- Manually add order item with fixed product_id in WooCommerce
- FacetWP group listings by custom field [closed]
- How to modify shortcode attributes with data from current post
- ‘Customize’ button in admin bar for CSS
- Wondering what these multi-colored extra pages are?
- Custom Post Type Plugin not loading category template and loading 404 instead
- Auto delete WordPress users according to time
- Plugin Customization Lost During Plugin Upgates
- Display content from custom post type if match to main post category
- Set the active Navigation Menu from a plugin
- How can i list random post from multiple category?
- Sidebar links for different pages
- Menus, but not by theme location
- How to import my YouTube channel into WordPress?
- Is it possible to use WordPress as an online portfolio for text content? What kind of theme would I look for?
- Custom Field Template seriously messed up in WP 3.1.1
- Set menu active state for custom posttype and category, given custom taxonomy term
- how to load the language file in plugin?
- Getting a List of Categories for Use in a Plugin?
- Plugin upgrade issue
- WP plugins for building a database?
- Not able to open category post [closed]
- How to use get_theme_mod in gutenberg editor wordpress?
- Get IDs of Images from Gallery Block in InnerBlocks of a Custom Gutenberg Block
- How to embed HTML code from WP Coder plugin (or other) into Main Index Template of the theme
- Loco Translate: Custom Post and Custom Taxonomy Labels not translated in wp-admin menu
- How to make a customize role and view a specific plugins base on that role?
- WordPress plugin – Error “Plugin generate 2890 characters of unexpected output when activated”
- How can I capture Memberpress user info after signup [closed]
- My plugin wants to update another plugin
- Where (or when) should I register a new taxonomy?
- I have no idea “How change font for elements in widget?”
- View Private Published Page with URL Code (no login required)
- Limit Number of Taxonomy Terms (Images) Displayed
- Widget for adding HTML markup to a page
- How I can get custom field’s current value?
- JS Support Ticket – Auto create WP account
- How to show Recent Page instead of Post?
- Remove Duplicator plugin from admin menu if not an administrator
- Input with spaces in Shortcode attributes overwritten by defaults
- WordPress JSON API remove posts from a specific category
- Easy Digital Download Sub category
- Solutions to repost categories into multisite blogs?
- Want wp_get_post_terms return in arbitrarily order, how to do?
- Add a custom form on the post-new.php admin page
- Removing customise fields during plugin uninstallation
- How to display only subcategory