Skip to content

Instantly share code, notes, and snippets.

@rilwis
Created July 23, 2016 01:48
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 rilwis/c795a07539a1b154b58d7b9651dec9b2 to your computer and use it in GitHub Desktop.
Save rilwis/c795a07539a1b154b58d7b9651dec9b2 to your computer and use it in GitHub Desktop.
MB Admin Columns - Add Custom Non-Meta Column
<?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
}
}
}
<?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