Skip to content

Instantly share code, notes, and snippets.

@tarikcayir
Created June 29, 2015 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarikcayir/3d78a91cb8390966cdae to your computer and use it in GitHub Desktop.
Save tarikcayir/3d78a91cb8390966cdae to your computer and use it in GitHub Desktop.
WP Meta-Box Example
<?php
/**
* Add the functions.php
*/
add_filter( 'rwmb_meta_boxes', 'motor_ozellikleri' );
function motor_ozellikleri( $meta_boxes )
{
$meta_boxes[] = array(
'title' => __( 'Motor Özelliklerini Giriniz', 'urun' ),
'fields' => array(
array(
'id' => 'car_properties',
'name' => __( 'Ozellikler', 'urun' ),
'type' => 'text_list',
'clone' => true,
'options' => array(
'Örn: Kapasite' => __( 'Özellik', 'urun' ),
'Örn: 1.293 ccm' => __( 'Değer', 'urun' ),
),
),
),
);
return $meta_boxes;
}
?>
<?php
/**
* Add the single.php
*/
?>
<div>
<h3>MetaBox</h3>
<?php
$car_properties = rwmb_meta( 'car_properties', $post_id );
echo '<pre>';
print_r($car_properties);
echo '</pre>';
foreach ($car_properties as $key => $value ) {
echo '<b>'.$value[0].'</b>: '.$value[1].'<br/>';
}
?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment