How to display meta_box field in listing

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 –

Read More
//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 –
Image of my admin post_type listing page

how can i add my meta_box field also in this listing.

Related posts

Leave a Reply

1 comment

  1. 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:

    add_filter( 'manage_brand_posts_columns', 'so20352744_manage_brand_posts_columns', 25, 1 );
    function so20352744_manage_brand_posts_columns( $cols )
    {
        $cols['brand'] = __( 'Brand', 'txt_domain' );
    
        return $cols;
    }
    

    and (b) add content to the column using the manage_posts_custom_column action hook:

    add_action( 'manage_posts_custom_column', 'so20352744_manage_posts_custom_column', 2, 1 );
    function so20352744_manage_posts_custom_column( $col )
    {
        global $post;
    
        switch ( $col )
        {
            case "brand" :
    
                if( '' != get_post_meta( $post->ID, 'brand_code', true ) )
                    echo get_post_meta( $post->ID, 'brand_code', true );
                else
                    echo __( 'N/A', 'txt_domain' );
    
                break;
    
            default :
                break;
        }
    }
    

    Both functions go in functions.php. More info: http://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column