Custom sorting for WordPress category lists

I’m creating a navigation menu that uses the get_categories() function to list all of my website’s categories. Currently, they’re sorted alphabetically, but I want them arranged in a specific custom order.

For instance, I’d like the categories to show up like this: About Us, Latest News, FAQ Section, Getting Started, Business Tips…

Here’s my existing code snippet:

$category_list = get_categories(array(
    'hide_empty' => false
));

foreach($category_list as $cat) {
    echo '<li><a href="' . get_category_link($cat->term_id) . '">' . $cat->name . '</a></li>';
}

Is there any parameter I can use to manage the display order manually? I’ve searched the WordPress documentation but haven’t found a straightforward solution for custom category sorting.

Had this same problem last year. Instead of messing with get_categories parameters, I just made an array with my category slugs in the order I wanted, then looped through it. Like $custom_order = ['about-us', 'latest-news', 'faq-section']; then foreach($custom_order as $slug) { $cat = get_category_by_slug($slug); if($cat) { echo '<li><a href="' . get_category_link($cat->term_id) . '">' . $cat->name . '</a></li>'; } }. Super simple - no plugins or database changes needed. You’ll have to update the array manually when you add categories, but that’s rarely a problem since most sites don’t change their category structure much.

try using ‘orderby’ => ‘include’ with an ‘include’ array for category IDs like get_categories(array(‘include’ => [5,12,8,3], ‘orderby’ => ‘include’)). it should work for ur custom order!

That approach works if you already know the category IDs, but I’ve found something more flexible using the menu_order field. You can set custom order values for each category with a plugin like Advanced Custom Fields, or just update the term_order field directly in your database. Another option is creating a custom array that maps category names to positions, then sorting after you pull them with get_categories(). Try something like usort($category_list, function($a, $b) { return $custom_order[$a->name] - $custom_order[$b->name]; }) where $custom_order has your sequence. This gives you full control without memorizing category IDs and makes changes way easier down the road.