7424 sujets

Développement web côté serveur, CMS

Bonjour,
j’ai un group metabox qui ressemble a ca, et que j’aimerai afficher dans une page spécifique :

add_action( 'cmb2_init', 'domaine_register_repeatable_group_field_metabox' );
function domaine_register_repeatable_group_field_metabox() {
  global $post;  
  $pageTemplate = get_post_meta($post->ID, '_wp_page_template', true);

  $prefix = 'klkchose';

  if($pageTemplate == 'test.php' ){
    $cmb_group = new_cmb2_box( array(
        'id'           => $prefix.'cmb_demo',
        'title'        => esc_html__( 'Repeating Field Group', 'cmb2' ),
        'object_types' => array( 'page', ),
    ) );


    $group_field_id = $cmb_group->add_field( array(
        'id'          => $prefix . 'demo',
        'type'        => 'group',
        'description' => esc_html__( 'Generates reusable form entries', 'cmb2' ),
        'options'     => array(
            'group_title'   => esc_html__( 'Dossier de compétence {#}', 'cmb2' ), // {#} gets replaced by row number
            'add_button'    => esc_html__( 'Add Another Entry', 'cmb2' ),
            'remove_button' => esc_html__( 'Remove Entry', 'cmb2' ),
            'sortable'      => true, // beta
            // 'closed'     => true, // true to have the groups closed by default
        ),
    ) );
    $cmb_group->add_group_field( $group_field_id, array(
        'name'       => esc_html__( 'Entry Title', 'cmb2' ),
        'id'         => 'title',
        'type'       => 'text',
        // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
    ) );
    $cmb_group->add_group_field( $group_field_id, array(
        'name'       => esc_html__( 'Votre Métier', 'cmb2' ),
        'id'         => 'title2',
        'type'       => 'text',
        // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
    ) );
    $cmb_group->add_group_field( $group_field_id,array(
        'name'     => esc_html__( 'Selectionner votre domaine', 'cmb2' ),
        'desc'     => esc_html__( 'field description (required)', 'cmb2' ),
        'id'       => $prefix . 'taxonomy_select',
        'type'     => 'taxonomy_select',
        'taxonomy' => 'job_listing_category', // Taxonomy Slug
    ) );
}  }

mais malheureusement ca ne m'affiche plus rien.
à l'aide svp
bonjour,

déjà ici:


add_action( 'cmb2_init', 'domaine_register_repeatable_group_field_metabox' );


es tu sur que le hook cmb2_init existe bien?