Skip to content

Instantly share code, notes, and snippets.

@clare485
Created December 3, 2013 14:46
Show Gist options
  • Save clare485/7770321 to your computer and use it in GitHub Desktop.
Save clare485/7770321 to your computer and use it in GitHub Desktop.
custom meta boxes
http://wordpress.org/plugins/meta-box/
https://github.com/humanmade/Custom-Meta-Boxes
require_once 'inc/custom_meta_boxes/custom-meta-boxes.php';
require_once 'inc/custom_meta_boxes/page_meta_box.php';
<?php
/*
* add meta boxes
*/
add_action( 'admin_init', 'rw_register_meta_boxes' );
function rw_register_meta_boxes()
{
if ( !class_exists( 'RW_Meta_Box' ) )
return;
$prefix = 'leven_';
$meta_boxes = array();
// 1st meta box
$meta_boxes[] = array(
'title' => 'Right hand sidebar',
'pages' => array( 'page' ),
'fields' => array(
array(
'name' => 'Right hand sidebar',
'desc' => '',
'id' => $prefix . 'right_hand_sidebar',
'type' => 'wysiwyg',
),
)
);
// testimonials
$meta_boxes[] = array(
'title' => 'Add property link',
'pages' => array( 'testimonial' ),
'fields' => array(
array(
'name' => 'Add name of property that this testimonial relates to eg "Helen stayed at Citadene Prestige in Kensington" Add link using link icon in wysiwyg box',
'id' => $prefix . 'property_name',
'type' => 'wysiwyg',
),
)
);
foreach ( $meta_boxes as $meta_box ) {
new RW_Meta_Box( $meta_box );
}
}
<?php if ( get_post_meta($post->ID, 'leven_right_hand_sidebar', true) ) : ?>
<div class="meta-sidebar">
<?php echo do_shortcode(rwmb_meta( 'leven_right_hand_sidebar' )); ?>
</div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment