• Resolved entumas

    (@entumas)


    Hi!

    I’m having problems with fields text_date and group

    I have this code in cmb2_mb.php:

    <?php
    	$mb_group = $mb -> add_field(array(
    		'id'          => 'mb_group',
    		'type'        => 'group',
    		'repeatable'  => false,
    		'options'     => array(
    			'group_title'   => 'Group:',
    			'sortable'      => false,
    		),
    	));
    
    	$mb -> add_group_field($mb_group, array(
    		'id'   => 'mb_group_text_date',
    		'type' => 'text_date',
    		'name' => 'Text date:',
    	));
    
    	$mb -> add_group_field($mb_group, array(
    		'id'   => 'mb_group_text',
    		'type' => 'text',
    		'name' => 'Text:',
    	));
    ?>

    Then this code in my single.php:

    <?php
    	$mb_group = get_post_meta(get_the_ID(), 'mb_group', true);
    	foreach ((array) $mb_group as $key => $entry) {
    
    		if (isset($entry['text_date'])) {
    			$text_date = esc_html($entry['text_date']);
    		}
    
    		if (isset($entry['mb_group_text'])) {
    			$mb_group_text = esc_html($entry['mb_group_text']);
    		}
    	}
    ?>

    But the field text_date is not printed.
    Other fields (text, radio_inline, select and text_time), if they are printed

    Can you help with this?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter entumas

    (@entumas)

    Sorry! I had a bad character in the declaration! :S

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    So you’re good to go and covered at this point entumas?

    One thing I notice with your single.php code is that you don’t echo anything.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problems with group and text_date’ is closed to new replies.