CMB2 repeatable group not showing up on page
-
I can’t figure out what is wrong with this code, why it isn’t showing up on the page. I’ve been follow this documentation on the wiki.
functions.php
/** * Front page carousel metabox */ add_action( 'cmb2_admin_init', 'front_page_carousel' ); function front_page_carousel() { $prefix = '_fp_'; $cmb = new_cmb2_box( array( 'id' => $prefix . 'carousel_metabox', 'title' => __( 'Front-page carousel', 'cmb2' ), 'object_types' => array( 'page' ), // Post type 'show_on' => array( 'key' => 'id', 'value' => array( 18 ) ), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, // Show field names on the left ) ); $group_field_id = $cmb->add_field( array( 'id' => $prefix . 'carousel_repeat_group', 'type' => 'group', 'options' => array( 'group_title' => __( 'Slide {#}', 'cmb2' ), 'add_button' => __( 'Add slide', 'cmb2' ), 'remove_button' => __( 'Remove slide', 'cmb2' ), 'sortable' => true, // beta ), ) ); $cmb->add_group_field( $group_field_id, array( 'name' => 'Titel', 'id' => 'title', 'type' => 'text', ) ); $cmb->add_group_field( $group_field_id, array( 'name' => 'Image', 'id' => 'image', 'type' => 'file', ) ); $cmb->add_group_field( $group_field_id, array( 'name' => __( 'Link', 'cmb2' ), 'id' => 'link', 'type' => 'text_url', 'protocols' => array( 'http' ), // Array of allowed protocols ) ); }
content-front-page.php
<div class="carousel"> <?php $entries = get_post_meta( get_the_ID(), $prefix . 'carousel_metabox', true ); foreach ( (array) $entries as $key => $entry ) { $img = $title = $link = ''; if ( isset( $entry['image_id'] ) ) { $img = wp_get_attachment_image( $entry['image_id'], 'share-pick', null, array( 'class' => 'full', ) ); } if ( isset( $entry['title'] ) ) { $title = esc_html( $entry['title'] ); } if ( isset( $entry['link'] ) ) { $link = esc_html( $entry['link'] ); } echo $entries; } ?> </div><!-- .carousel -->
All I get is an black page with an empty carousel div and tears in my eyes
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘CMB2 repeatable group not showing up on page’ is closed to new replies.