Last active
August 29, 2015 13:58
-
-
Save petenelson/10294782 to your computer and use it in GitHub Desktop.
WordPress: Custom post type columns with array insert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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