• I am having a hard time figuring out what am doing wrong. I am trying to include my meta-box code directly (i.e am not installing meta-box as a plugin) to my source.

    Here is my code

    
    require plugin_dir_path(__FILE__) . '/ext/meta-box/meta-box.php';
    
    // Custome post type
    function security_compliance_prototype() {
      register_post_type( 'security_compliance',
        array(
          'labels' => array(
            'name' => __( 'Security Compliance' ),
            'add_new' => __('Add New Declaration'),
            'add_new_item' => __('Add New declaration'),
            'search_items' => __('Search Declarations'),
            'view_item' => __('View declaration'),
            'view_items' => __('View declarations'),
          ),
          'public' => true,
          'has_archive' => true,
        )
      );
    }
    
    add_action('init', 'security_compliance_prototype');
    
    function declarationMeta($meta_boxes){
      $prefix = 'sc_pro_';
      $meta_boxes[] = array(
        'title'      => __( 'Test Meta Box', 'textdomain' ),
        'post_types' => 'post',
        'fields'     => array(
                          array(
                            'id'   => 'name',
                            'name' => __( 'Name', 'textdomain' ),
                            'type' => 'text',
                          ),
                        ),
      );
      return $meta_boxes;
    }
    
    add_filter( 'rwmb_meta_boxes', 'declarationMeta' );
    
    

    I am expecting to see a field that a user can fill out in the custom post type. What can be wrong here?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Trouble adding the meta-box code directly to my plugin’ is closed to new replies.