EDIT
I don’t really know of a solution within WordPress to sort the way you need. I think the best is to make use of php sorting to sort your returned array as needed
Here is how:
-
Get the array of category info as you normally do
$categories = get_categories($args);
$categories
will hold an array of the five categories returned from the database
-
You now need to create an array with your desired sort order
$keys = [1,3,4,2,5];
-
You are now going to combine
$keys
and$categories
witharray_combine
. We will use the values ofSkeys
for the keys for our new combined array$categories_rearranged = array_combine( $keys, $categories );
-
At this stage, your array will not be naturally sorted, so with the use of
ksort
, sort your array so that it is ordered naturallyksort($categories_rearranged);
-
$categories_rearranged
will now be the array that you will make use of and will be passed to yourforeach
loopforeach ( $categories_rearranged as $category ) { echo $category->name; }
ORIGINAL ANSWER
The codex is there to help you. Look at get_categories()
and in particular to the following parameters
orderby
(string) Sort categories alphabetically or by unique category ID. The default is sort by name. Valid values:
id
name – default
slug
count
term_group
You can see you are passing an invalid parameter to orderby
The include
and exclude
parameters cannot be used together as well