Ask your WordPress questions! Pay money and get answers fast! (more info)

Using Meta Box plugin unable to display values on home page WordPress


I am using this plugin:

I have followed the instructions (used it before and not had problems) and all of the data is being saved when editing the page but when I try to echo out the values on the home page nothing displays.

Here is the contents of the demo.php file

* Registering meta boxes
* All the definitions of meta boxes are listed below with comments.
* Please read them CAREFULLY.
* You also should read the changelog to know what has been changed before updating.
* For more information, please visit:
* @link

/********************* META BOX DEFINITIONS ***********************/

* Prefix of meta keys (optional)
* Use underscore (_) at the beginning to make keys hidden
* Alt.: You also can make prefix empty to disable it
// Better has an underscore as last sign
$prefix = 'section1_';

global $meta_boxes;

$meta_boxes = array();

// 1st meta box
$meta_boxes[] = array(
// Meta box id, UNIQUE per meta box. Optional since 4.1.5
'id' => 'section1',

// Meta box title - Will appear at the drag and drop handle bar. Required.
'title' => 'Section One',

// Post types, accept custom post types as well - DEFAULT is array('post'). Optional.
'pages' => array( 'page' ),

// Where the meta box appear: normal (default), advanced, side. Optional.
'context' => 'normal',

// Order of meta box: high (default), low. Optional.
'priority' => 'high',

// List of meta fields
'fields' => array(
// Field name - Will be used as label
'name' => 'Title',
// Field ID, i.e. the meta key
'id' => "text",
// Field description (optional)
'desc' => 'Text description',
'type' => 'text',
// Default value (optional)
// CLONES: Add to make the field cloneable (i.e. have multiple value)
'name' => 'Content',
'id' => "{$prefix}wysiwyg",
'type' => 'textarea',
'std' => '',

'name' => 'Content',
'id' => "{$prefix}wysiwyg2",
'type' => 'textarea',
'std' => '',

'name' => 'Content',
'id' => "{$prefix}wysiwyg3",
'type' => 'textarea',
'std' => '',



/********************* META BOX REGISTERING ***********************/

* Register meta boxes
* @return void
function section1_register_meta_boxes()
// Make sure there's no errors when the plugin is deactivated or during upgrade
if ( !class_exists( 'RW_Meta_Box' ) )

global $meta_boxes;
foreach ( $meta_boxes as $meta_box )
new RW_Meta_Box( $meta_box );
// Hook to 'admin_init' to make sure the meta box class is loaded before
// (in case using the meta box class in another plugin)
// This is also helpful for some conditionals like checking page template, categories, etc.
add_action( 'admin_init', 'section1_register_meta_boxes' );

And I am using this to echo the value of the first text field whose ID is 'text'

<?php echo rwmb_meta( 'text' ); ?>

I've also tried

<?php $meta = get_post_meta( get_the_ID(), 'text', true ); echo $meta; ?>

Nothing gets displayed.

Any help would be appreciated.

Answers (1)


Dbranes answers:


does this shows anything:

echo "<pre>";
$customs = get_post_custom(get_the_ID());
$text = (isset($customs['text'][0]))?$customs['text'][0]:"";
echo "<br/>text=".$text;
echo "</pre>";

Dan | gteh comments:

That displays all of the data.


array(1) {

So I see the problem now. "YOUR_PREFIX_" is the default prefix assigned by the plugin. I don't know why the prefix is being added to the ID since I have a) given a new prefix "section1_" and tried removing {$prefix} from the ID.

So.. If I do this:

<?php echo rwmb_meta( 'YOUR_PREFIX_text' ); ?>

then it works.

But why is YOUR_PREFIX being added?

Dbranes comments:

ok, do you have any "section1_text" from the meta dump?

Dbranes comments:

maybe you should try to replace

'id' => "text",


'id' => {$prefix}text",

just to see if that works with your new prefix.

ps: here is the function rwmb_meta() defined:

its based on

$meta = get_post_meta( $post_id, $key, !$args['multiple'] );

just like you tried.