0

I'm using the Humanmade | Custom meta box class to add meta boxes to my themes admin pages.

I have integrated the class and have been enjoying the use of adding meta box's to my current projects immensely. I've now come into an area where I'm very stuck.

I have a created a repeatable meta box group.

$featurettes = array(

    array( 'id' => 'a_feat_img', 'name' => 'Featurette Illustration or image',                'type' => 'image', 'cols' => 4, 'show_size' => true ),

    array( 'id' => 'a_feat_head',  'name' => 'Featurette heading', 'type' => 'text', 'cols' => 4 ),

    array( 'id' => 'a_feat_sub',  'name' => 'Featurette subheading or description', 'type' => 'textarea', 'cols' => 4 )
);

$group_featurettes = $featurettes;
foreach ( $group_featurettes as &$featurette ) {
    $featurette['id'] = str_replace( 'featurette', 'gfeaturette', $featurette['id'] );
}

$meta_boxes[] = array(
    'title' => 'About Page Featurettes',
    'pages' => 'page',
    'show_on' => array( 'id' => array( 6 ) ),
    'fields' => array(
        array( 
            'id' => 'a_f_gp', 
            'name' => 'Featurette Panels', 
            'type' => 'group', 
            'repeatable' => true,
            'sortable' => true,
            'fields' => $group_featurettes,
            'desc' => 'Create featurettes.'
        ),
    )
);

In the back end this works perfectly.

As far as I've got with displaying the meta.

<section class="row featurette-wrap">

    <aside class="large-4 columns featurette-img">
        <?php echo wp_get_attachment_image( get_post_meta( get_the_id(), 'a_feat_img', true ), 'thumbnail', false, array( 'class' => 'vert-align-mid' ) ); ?>
    </aside>
    <article class="large-8 columns featurette-text">
        <?php 
            $groups = get_post_meta( get_the_id(), 'a_f_gp', false );

            foreach ( $groups as $group ) {        
                echo '<h2 class="vert-align-mid">' . $group['a_feat_head'] . '</h2>';
                echo '<h4 class="vert-align-mid">' . $group['a_feat_sub'] . '</h4>';
            }
        ?>      
    </article>
</section>

What I'd like to do

I want to create a loop that displays a new <section class="row featurette-wrap"> and everything in it for each repeated group made in the admin area.

What I have here

<?php 
    $groups = get_post_meta( get_the_id(), 'a_f_gp', false );

    foreach ( $groups as $group ) {        
        echo '<h2 class="vert-align-mid">' . $group['a_feat_head'] . '</h2>';
        echo '<h4 class="vert-align-mid">' . $group['a_feat_sub'] . '</h4>';
    }
?>

Will display new information but I'd like to include the whole group and it's containing elements.

Can anyone point me in the right direction with this? Any suggestions or advice would be greatly appreciated.

Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.