◦ Comprehensive security
◦ 24/7 support
WordPress Guide → Post → Sort Posts
How to sort WordPress posts within a category
WordPress shows posts by newest first—but what if you want to feature your most important content first, or display posts in a specific order by category? Whether you’re managing a product catalog, tutorial series, or event listing, sorting posts within a category helps improve navigation and keeps your content organized.
Let’s explore the best ways to do this using both plugins and code, with detailed step-by-step guidance.
Get fast, reliable hosting for WordPress
Power your site with the industry’s fastest, most optimized WordPress hosting
1. Use drag-and-drop plugins for manual control
Plugins are the easiest way to control post order without touching code. Most offer drag-and-drop sorting or category-specific options.
Simple Custom Post Order
The Simple Custom Post Order plugin adds drag-and-drop support directly inside your Posts list.
How to use it:
- Go to Plugins > Add New.
- Search for Simple Custom Post Order.
- Click Install Now, then Activate.
- Go to Settings > SCPOrder.
- Under “Sort by,” check the box for Posts.
- Click Update to save settings.
- Now go to Posts > All Posts.
- Use the drag-and-drop handles to reorder posts.
To sort within a category only:
- Use the dropdown filter at the top of the Posts page to select a category.
- Once filtered, drag posts into the order you want.
- The new order will be reflected when viewing that category archive.
This method is great when you want full manual control but don’t need sorting by custom fields or date logic.
Post Types Order (by Nsp Code)
Post Types Order offers more flexibility, especially for custom post types and taxonomies.
How to use it:
- Go to Plugins > Add New.
- Search for Post Types Order.
- Click Install Now, then Activate.
- Visit Settings > Post Types Order.
- Ensure “Show re-order interface” is checked for Posts.
- Optional: Enable or disable admin sort override and archive sort override depending on your setup.
- Go to Posts > Re-Order.
- Drag and drop your posts into the desired order.
- Filter by category if needed using the top dropdown (optional).
This plugin also supports advanced queries, custom post types, and multisite setups. If you ever expand beyond simple blog posts, it’s worth keeping installed.
2. Sort posts within a category using code
If you’re comfortable editing PHP and want to apply dynamic logic—like sorting by a custom field or alphabetically—this method gives you full control.
Add custom sorting with pre_get_posts
The pre_get_posts hook lets you modify how WordPress queries posts on category pages.
Example: Sort posts by a custom field called “priority”
function my_custom_category_sort( $query ) {
if ( is_category() && $query->is_main_query() ) {
$query->set( 'orderby', 'meta_value' );
$query->set( 'order', 'ASC' );
$query->set( 'meta_key', 'priority' );
}
}
add_action( 'pre_get_posts', 'my_custom_category_sort' );To use this code:
- Go to Appearance > Theme File Editor.
- In the right sidebar, select functions.php (under your active theme).
- Paste the code at the bottom of the file.
- Click Update File.
Important notes:
- This code only runs on category archive pages.
- The posts must have a custom field named priority.
- You can manage custom fields with a plugin like Advanced Custom Fields.
3. Use custom WP_Query in template files (advanced)
If you’re building or modifying a theme, you can manually control how posts are queried in category.php.
Example: Sort posts alphabetically by title
$args = array(
'cat' => get_queried_object_id(),
'orderby' => 'title',
'order' => 'ASC'
);
$custom_query = new WP_Query( $args );
if ( $custom_query->have_posts() ) :
while ( $custom_query->have_posts() ) : $custom_query->the_post();
// Display your post content
endwhile;
wp_reset_postdata();
endif;This gives you granular control but should only be used if you’re familiar with child themes and template file editing.
Choosing the best method for your site
Which strategy will be most helpful for you depends on your specific needs and your technical know-how.
- Use Simple Custom Post Order for visual drag-and-drop reordering inside a category.
- Use Post Types Order for more advanced and scalable drag-and-drop sorting.
- Use code or custom queries if you need full control over sort logic (e.g., by custom field or alphabetical).
Next steps for sorting WordPress posts within a category
Reordering posts by category helps structure your content in a way that aligns with your goals—whether it’s improving usability, SEO, or product discovery. With beginner-friendly plugins or a few lines of code, you can easily take control of how posts appear across your site.
Start by installing a plugin like Simple Custom Post Order or Post Types Order to experiment with different layouts. If you need to sort posts dynamically by custom data, try the pre_get_posts method or use a custom loop in your theme.
Ready to upgrade your WordPress experience? Professional hosting improves speeds, security, and reliability for a website and a brand that people find engaging and trustworthy.
Don’t want to deal with server management and maintenance? Our fully managed hosting for WordPress is the best in the industry. Our team are not only server IT experts, but WordPress hosting experts as well. Your server couldn’t be in better hands.
Click through below to explore all of our hosting for WordPress options, or chat with a WordPress expert right now to get answers and advice.
Additional resources
What is WordPress? →
A complete beginner’s guide to WordPress.org
Can you un-delete a WordPress category? No, but you CAN …→
Learn how to recover or recreate deleted WordPress categories to restore site organization.
Beginner’s Guide to WordPress themes →
Learn how they work, what to look for, how to choose, and more