Meta Box Plugin – setup & display

add_filter( 'rwmb_meta_boxes', 'model_homes_meta_boxes' );  
function model_homes_meta_boxes ( $meta_boxes ) {
 	 	$prefix = 'rw_';
 	 	$meta_boxes[] = array(
 		'id' => 'gallery',
 		'title' => 'Gallery Images',
 		'pages' => array ('model','show_homes','homes_for_sale'),
 		'fields' => array(
 			array(
 				'name' => __( 'Interior and Exterior Gallery Image Upload', 'meta-box' ),
 				'id' => "{$prefix}imgadv",
 				'type'  => 'image_advanced',
 				'max_file_uploads' => 24
 			),
 		)
 	);
$meta_boxes[] = array(
 		'id' => 'floor_plan',
 		'title' => 'Floor Plan Images',
 		'pages' => array ('model','show_homes','homes_for_sale'),
 		'fields' => array(
 			array(
 				'name' => __( 'Floor Plan Image Upload', 'meta-box' ),
 				'id'   => "{$prefix}image",
 				'type' => 'image',
 				'max_file_uploads' => 4
 			),
 		)
 	);
return $meta_boxes; }

 

function model_show_homes() {
 	if (is_singular('model') || is_singular('show_homes') || is_singular('homes_for_sale') ) {
 	$metas = get_post_meta( get_the_ID(), 'rw_imgadv', false );
 	if (!empty($metas)) { 	?>
 	<div id="gallery_wrap">
 		<div class="wrap">
 			<div class="sidebar">
 				<h3>Photos</h3>
 			</div>
 			<div class="content">
 				<ul>
 					<?php // If you want to show values
 					/* echo '<pre>';
 					print_r($metas);
 					echo '</pre>';	*/
 		 					foreach ( $metas as $meta ) { ?>
<li><a href="<?php echo wp_get_attachment_url( $meta ); ?>">
<img src="<?php echo wp_get_attachment_url( $meta ); ?>"/></a>
</li>
<?php
 					} ?>
 				</ul>
 			</div>
 		</div>
 	</div>
 	<? }  $metas = get_post_meta( get_the_ID(), 'rw_image', false );
 	 	if (!empty($metas)) { ?>
 	<div id="floorplan_wrap">
 		<div class="wrap">
 			<div class="sidebar">
 				<h3>Floorplans</h3>
 			</div>
 			<div class="content">
 				 				<ul>
 					<?php foreach ( $metas as $meta ) { ?>
<li><a href="<?php echo wp_get_attachment_url( $meta ); ?>">
<img src="<?php echo wp_get_attachment_url( $meta ); ?>"/>
</a></li><?php 	} ?>
 				</ul>
 			</div>
 		</div>
 	</div>
 	<?php }
 	}
 } 
add_action('thematic_abovefooter','model_show_homes');

Follow the demo.

Leave a Reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.