I am creating one post_type using register_post_type so i am getting add_new option there i am using meta_box to use my custom field.But in my listing it is showing only title column,How i can use my meta_box field as a column in listing page.
my code for register_post_type is –
// Create Brand Management
add_action('init', 'manage_brand');
function manage_brand() {
register_post_type('brand', array(
'labels' => array(
'name' => 'Manage Brand',
'singular_name' => 'Manage Brand',
'add_new' => 'Add New',
'add_new_item' => 'Add New Brand',
'edit' => 'Edit',
'edit_item' => 'Edit Brand',
'new_item' => 'New Brand',
'view' => 'View',
'view_item' => 'View Brand',
'search_items' => 'Search Brand',
'not_found' => 'No Brand',
'not_found_in_trash' => 'No Brand found in Trash',
'parent' => 'Parent News Brand'
),
'public' => true,
'menu_position' => 100,
'supports' => array('','thumbnail'),
'taxonomies' => array('project-cat'),
'menu_icon' => plugins_url('images/adv-.png', __FILE__),
'has_archive' => true,
)
);
}
and my code to add field using meta_box is –
//add meta data for brand
add_action('admin_init', 'brand_register_meta_boxes');
function brand_register_meta_boxes() {
if (!class_exists('RW_Meta_Box'))
return;
$prefix = 'brand_';
$meta_boxes[] = array(
'title' => 'Add Brand',
'pages' => array('brand'),
'fields' => array(
array(
'name' => __( 'Brand Name', 'rwmb' ),
'desc' => __( 'Add Brand Name', 'rwmb' ),
'id' => "{$prefix}code",
'type' => 'text',
'required' => true,
),
)
);
foreach ($meta_boxes as $meta_box) {
new RW_Meta_Box($meta_box);
}
}
my list page is coming like this with tile only –
how can i add my meta_box field also in this listing.
Assuming the value of the meta box is stored as post meta, you should (a) register a custom column using the dynamic
manage_{$post_type}_posts_columns
filter hook:and (b) add content to the column using the
manage_posts_custom_column
action hook:Both functions go in
functions.php
. More info: http://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column