Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * functions.php
- *
- * this code creates the metabox object
- */
- // include the class in your theme or plugin
- include_once 'WPAlchemy/MetaBox.php';
- // include css to help style our custom meta boxes ( if necessary - uncomment and fix paths )
- // if ( is_admin() ) { wp_enqueue_style( 'custom_meta_css', get_bloginfo( 'stylesheet_directory' ) . '/custom/meta.css' ); }
- // create the metabox object
- $custom_metabox = new WPAlchemy_MetaBox( array(
- 'id' => '_mcms_testimonial', // prefixing with an underscore will hide it from the 'Custom Fields' box
- 'title' => 'Testimonials', // title of the box
- 'types' => array( 'custom_post_type_slug' ), // post types
- 'template' => STYLESHEETPATH . '/custom/meta.php' // the actual metabox ( fix paths if necessary )
- )
- );
- ?>
- <?php
- /**
- * meta.php
- *
- * this defines the guts of the metabox
- * the HTML/CSS is up to you
- */
- ?>
- <div class="mcms_optinpage">
- <?php while( $mb->have_fields_and_multi( 'testimonials' ) ): ?>
- <?php $mb->the_group_open(); ?>
- <?php $mb->the_field( 'name' ); ?>
- <label>Testimonial Name</label><div class='description'>Enter the name of your testimonial.</div>
- <p><input type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>" /></p>
- <?php $mb->the_field( 'content' ); ?>
- <label>The Testimonial</label><div class='description'>Enter the testimonial which your prospect gave you.</div>
- <p><textarea type="text" name="<?php $mb->the_name(); ?>"><?php $mb->the_value(); ?></textarea></p>
- <?php $mb->the_field( 'audio' ); ?>
- <label>OPTIONIAL Testimonial Audio Button</label><div class='description'>Enter the URL to the mp3 of your testimonial.</div>
- <p><input type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>" /></p>
- <?php $mb->the_group_close(); ?>
- <?php endwhile; ?>
- <p>
- <a href="#" class="docopy-testimonials button">Add Testimonial</a>
- </p>
- </div>
- <?php
- /**
- * custom-post-type-template.php
- *
- * use this to retrieve the meta values in the template ( inside a WP loop )
- * the HTML is up to you, this will simply echo the values out
- */
- // WP Alchemy metabox
- global $custom_metabox;
- // get the meta data for the current post
- $custom_metabox->the_meta();
- // loop a set of field groups
- while( $custom_metabox->have_fields( 'testimonials' ) )
- { ?>
- <p>
- <?php $custom_metabox->the_value( 'name' ); ?>
- </p>
- <p>
- <?php $custom_metabox->the_value( 'content' ); ?>
- </p>
- <?php // checking if a value exists
- if ( $custom_metabox->get_the_value( 'audio' ) ) { ?>
- <p>
- <?php $custom_metabox->the_value( 'audio' ); ?>
- </p>
- <?php } ?>
- <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment