0

I have simple array from Wordpress manage_posts_columns filter, to change the columns in custom post type admin. The array looks like

$columns = array ('lastname' => 'Lastname', 'firstname' => 'Firstname', 'city' => 'City' );

and I'm adding ID column

$columns['id'] = 'ID';

I would need to move the id element to second position in the array. How can this be done?

user1049961
  • 2,656
  • 9
  • 37
  • 69

1 Answers1

0

Instead, you can use array_unshift to prepend elements onto an array, or array_push to add an element at the end of the array.

To reorder the associative array, you can use array_splice. A good example is here: http://uk.php.net/manual/en/function.array-splice.php#92651

Rob W
  • 9,134
  • 1
  • 30
  • 50