Category specific order

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:

  1. 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

  1. You now need to create an array with your desired sort order

    $keys = [1,3,4,2,5];
    
  2. You are now going to combine $keys and $categories with array_combine. We will use the values of Skeys for the keys for our new combined array

    $categories_rearranged = array_combine( $keys, $categories );
    
  3. At this stage, your array will not be naturally sorted, so with the use of ksort, sort your array so that it is ordered naturally

    ksort($categories_rearranged);
    
  4. $categories_rearranged will now be the array that you will make use of and will be passed to your foreach loop

    foreach ( $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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)