Created
July 23, 2016 01:48
-
-
Save rilwis/c795a07539a1b154b58d7b9651dec9b2 to your computer and use it in GitHub Desktop.
MB Admin Columns - Add Custom Non-Meta Column
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
<?php | |
class Prefix_Custom_Admin_Columns extends MB_Admin_Columns_Post { | |
public function columns( $columns ) { | |
$columns = parent::columns( $columns ); | |
/** | |
* Add more column in a specific position | |
* | |
* @param string $position New column position. Empty to not specify the position. Could be 'before', 'after' or 'replace' | |
* @param string $target The target column. Used with combination with $position | |
*/ | |
$position = ''; | |
$target = ''; | |
$this->add( $columns, 'column_id', 'Column Title', $position, $target ); | |
// Add more if you want | |
return $columns; | |
} | |
public function show( $column, $post_id ) { | |
switch ( $column ) { | |
case 'column_id': | |
echo 'Column content'; | |
break; | |
// More columns | |
} | |
} | |
} |
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
<?php | |
add_action( 'admin_init', 'prefix_add_custom_columns', 20 ); | |
function prefix_add_custom_columns() { | |
require_once 'custom.php'; | |
new Prefix_Custom_Admin_Columns( 'post', array() ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment