CMB2 repeatable group field metabox
-
Buenos días,
Tengo un pequeño problema con cmb2 repeatable group field metabox.
Después de añadir los campos y valores no veo nada en la pantalla ni un mensaje de error .
Aquí tengo el código:add_action( 'cmb2_admin_init', 'aa_projects_register_repeatable_group_field_metabox' ); /** * Hook in and add a metabox to demonstrate repeatable grouped fields */ function aa_projects_register_repeatable_group_field_metabox() { // Start with an underscore to hide fields from custom fields list $prefix = '_aa_projects_group_'; /** * Repeatable Field Groups */ $cmb_group = new_cmb2_box( array( 'id' => $prefix . 'metabox', 'title' => __( 'Repeating Field Group', 'farmacias' ), 'object_types' => array( 'post', 'farmacias' ), // Post type ) ); // $group_field_id is the field id string, so in this case: $prefix . 'demo' $group_field_id = $cmb_group->add_field( array( 'id' => $prefix . 'slides', 'type' => 'group', 'description' => __( 'Generates reusable form entries', 'farmacias' ), 'options' => array( 'group_title' => __( 'Entry {#}', 'farmacias' ), // {#} gets replaced by row number 'add_button' => __( 'Add Another Entry', 'farmacias' ), 'remove_button' => __( 'Remove Entry', 'farmacias' ), 'sortable' => true, // beta // 'closed' => true, // true to have the groups closed by default ), ) ); $cmb_group->add_group_field( $group_field_id, array( 'name' => __( 'Titel', 'farmacias' ), 'id' => 'title', 'type' => 'text', // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types) ) ); }
================ En mi página ======================
<?php if(have_posts()): while(have_posts()): the_post(); $entries = get_post_meta( get_the_ID(), 'metabox', true ); foreach ( (array) $entries as $key => $entry ) { if ( isset( $entry['title'] ) ) $title = esc_html( $entry['title'] ); // Output the values if ( !empty($title) ) echo '<h2>'.$title.'</h2>'; } ?> <?php endwhile; else : ?> <h3>Sorry we could not find what you are looking for </h3> <?php endif; ?>
Gracias
Viendo 2 respuestas - de la 1 a la 2 (de un total de 2)
Viendo 2 respuestas - de la 1 a la 2 (de un total de 2)
- El debate ‘CMB2 repeatable group field metabox’ está cerrado a nuevas respuestas.