We help IT Professionals succeed at work.

Add a Custom post type custom field to WordPress Screen options

High Priority
851 Views
Last Modified: 2018-06-25
I have a created a custom meta box with field called model_num using CMB2 for my custom Taxonomy. Is it possible to show that field under WordPress Screen Options

add_action( 'cmb2_init', 'pc_register_product_items_metabox' ); 
function pc_register_product_items_metabox() {

	// Start with an underscore to hide fields from custom fields list
	$prefix = '_pc_prod_';
	
	$cmb_prod = new_cmb2_box( array(
		'id'            => $prefix . 'product_items_metabox',
		'title'         => __( '<strong style="font-size:20px;text-transform:uppercase;">Badge Item Details</strong>', 'cmb2' ),
        'object_types' => array( 'badge-gallery-item' ), // post type
		'context'       => 'normal',
		'priority'      => 'high',
		'show_names'    => true, // Show field names on the left

	) );
	
    $cmb_prod->add_field( array(
    'name' => 'Badge Model Number',
    'desc' => 'enter badge model number below, that be referenced by customers when they call in',
    'id'   => $prefix . 'model_num',
    'type' => 'text',
    'default' => '',
    ) );
	
}

Open in new window



Thanks & Appreciate it
Comment
Watch Question

Scott FellDeveloper & EE Moderator
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2013

Commented:
Do you still need help with this?

Author

Commented:
Yes please and thanks
Developer & EE Moderator
CERTIFIED EXPERT
Fellow
Most Valuable Expert 2013
Commented:
I looked into this a little bit.  First of all, the options already show up on the page below the content area.  I would leave it as is. Otherwise, if you want to pursue using the screen options tab, I found these blog posts to be a good possible solution but would take some work where you just need to replace the content used with the cmb plug in.  

http://lance.bio/2017/06/15/adding-screen-options-to-wordpress-admin-pages/ 
http://lance.bio/2017/06/16/adding-columns-to-wordpress-screen-options/