Skip to content

Instantly share code, notes, and snippets.

@petenelson
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petenelson/10294782 to your computer and use it in GitHub Desktop.
Save petenelson/10294782 to your computer and use it in GitHub Desktop.
WordPress: Custom post type columns with array insert
function array_insert($array, $values, $offset) {
// http://stackoverflow.com/questions/1783089/array-splice-for-associative-arrays/11114956#11114956
return array_slice($array, 0, $offset, true) + $values + array_slice($array, $offset, NULL, true);
}
function admin_columns($columns) {
// this is the 'manage_edit-{post-type}_columns' filter
// add_filter( 'manage_edit-' . self::$post_type . '_columns', array($this, 'admin_columns'), 10, 1 ) ;
$columns = array_insert($columns, array('sales-channel' => 'Sales Channel'), 2);
return $columns;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment