Skip to content

Instantly share code, notes, and snippets.

@rilwis

rilwis/custom.php

Created Jul 23, 2016
Embed
What would you like to do?
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
You can’t perform that action at this time.