Custom Fields
Re-Envisioned
Support General Fields are not displayed in custom post type edit form

This topic contains 1 reply, has 2 voices, and was last updated by  Anh Tran 2 months ago.

  • Creator
    Topic
  • #15713

    khaz
    Participant

    Hello,

    I don’t have fields on the edit form for my CPT and I don’t understand what is wrong. I created a custom post type with a yeoman template :

      register_post_type( 'so_offer', array(
        'description'          => 'Offre d\'estimation ou devis',
        'labels'               => array(
          'name'               => _x( 'Offres', 'post type general name', 'so_flowbiz' ),
          'singular_name'      => _x( 'Offre', 'post type singular name', 'so_flowbiz' ),
          'menu_name'          => _x( 'Offres', 'admin menu', 'so_flowbiz' ),
          'name_admin_bar'     => _x( 'Offre', 'add new so_offer on admin bar', 'so_flowbiz' ),
          'add_new'            => _x( 'Ajouter', 'post_type', 'so_flowbiz' ),
          'add_new_item'       => __( 'Ajouter nouvelle offre', 'so_flowbiz' ),
          'edit_item'          => __( 'Éditer offre', 'so_flowbiz' ),
          'new_item'           => __( 'Nouvelle offre', 'so_flowbiz' ),
          'view_item'          => __( 'Voir offre', 'so_flowbiz' ),
          'search_items'       => __( 'Rechercher offre', 'so_flowbiz' ),
          'not_found'          => __( 'Aucune offre trouvée.', 'so_flowbiz' ),
          'not_found_in_trash' => __( 'Aucune offre trouvée dans la corbeille.', 'so_flowbiz' ),
          'all_items'          => __( 'Toutes les offres', 'so_flowbiz' ),
        ),
        'public'               => true,
        'hierarchical'         => false,
        'exclude_from_search'  => true,
        'publicly_queryable'   => true,
        'show_ui'              => true,
        'show_in_menu'         => true,
        'show_in_nav_menus'    => true,
        'show_in_admin_bar'    => true,
        'menu_position'        => 10,
        'menu_icon'            => 'dashicons-universal-access-alt',
        'capability_type'      => 'post',
        'capabilities'         => array(),
        'map_meta_cap'         => null,
        'supports'             => array( 'title', 'editor', 'author', 'revisions', 'custom-fields' ),
        'taxonomies'           => array(),
        'has_archive'          => "offers",
        'rewrite'              => array(
          'slug'       => 'offer',
          'with_front' => true,
          'feeds'      => true,
          'pages'      => true,
        ),
        'query_var'            => true,
        'can_export'           => true,
      ) );
    }
    add_action('init', 'so_register_offer', 15, 0);

    And for example, a metabox like :

    
        $meta_boxes[] = array(
            'id' => 'so_offer_standalone',
            'title' => esc_html__( 'Offre autonome', 'so_flowbiz' ),
            'context' => 'after_title',
            'priority' => 'normal',
            'autosave' => 'false',
            'hidden' => array( $prefix . 'offer_type', '!=' ,'standalone'),
            'storage_type' => 'custom_table',
            'table'        => $wpdb->prefix.'flowbiz_offers',
            'fields' => array(
                array(
                    'id' => $prefix . 'customer_registered',
                    'type' => 'radio',
                    'name' => esc_html__( 'Attribution du client', 'so_flowbiz' ),
                    'desc' => '',
                    'options' => array(
                        'true' => 'Client enregistré',
                        'false' => 'Client externe'
                    ),
                    'inline' => true
                )
            )
        );

    I don’t see any meta box. In the screen options of the edit form (on the top of the screen), there is no custom fields, nor meta boxes checkbox.
    I have the extensions MB Custom Table, MB Relationships and Meta Box Conditional Logic activated.
    Any idea ?
    Is there a hook to check when the meta boxes are added in the edit form ?

    Thanks !

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #15731

    Anh Tran
    Keymaster

    Hi,

    I see you miss the post_types parameter for the meta box. It should point to your custom post type:

    'post_types' => ['so_offer'],
    
Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.