Adding a Meta Box for a Custom Post Type?

Support MB Custom Post Type Adding a Meta Box for a Custom Post Type?Resolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #45489
    Andrew TegenkampAndrew Tegenkamp
    Participant

    I have a custom post type "Careers" with slug "career" and it works well to create a new entry. I'm trying to create a meta box for it called "Career Data" that is a WYSIWYG meta box. I've added this code but it shows "Career Data" on Posts and not on "Careers" ... what did I do wrong?

    
    add_filter('rwmb_meta_boxes', 'career_data');
    function career_data($meta_boxes) {
    	$meta_boxes[] = [
    		'title' => 'Career Data',
    		'fields' => [
    			[
    				'id'   => 'career_data',
    				'name' => 'Wages',
    				'type' => 'wysiwyg',
    				'post_types' => ['career'],
    			],
    		],
    	];
    	return $meta_boxes;
    }
    

    Thanks!

    #45493
    Andrew TegenkampAndrew Tegenkamp
    Participant

    Well, this was my silly mistake as I put the post_types inside the fields array. I moved it out and it worked perfectly. Feel free to delete this question or mark it as solved with the corrected code below! On to tabs...

    
    add_filter('rwmb_meta_boxes', 'career_data');
    function career_data($meta_boxes) {
    	$meta_boxes[] = [
    		'title' => 'Career Data',
    		'fields' => [
    			[
    				'id'   => 'career_data',
    				'name' => 'Wages',
    				'type' => 'wysiwyg',
    				//'visible' => [ 'post_type', 'career' ],
    			],
    		],
    		'post_types' => ['career'],
    	];
    	return $meta_boxes;
    }
    
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.