Viewing 6 replies - 1 through 6 (of 6 total)
  • You’re not doing it correct.

    It has all been explained and described with examples here.

    Basically you echo the values in your theme files like:
    echo rwmb_meta( 'dob' ); (where dob is the ID of your field

    Thread Starter maestro_jules

    (@maestro_jules)

    thanks for your response @ Piet. This is what i saw:

    $images = rwmb_meta( 'gallery', 'type=image' );
    foreach ( $images as $image )
    {
        echo "<a href='{$image['full_url']}' title='{$image['title']}' rel='thickbox'><img src='{$image['url']}' width='{$image['width']}' height='{$image['height']}' alt='{$image['alt']}' /></a>";
    }

    I am wondering after changing ‘gallery’ to ‘my field id’, is there anything else to change. I don’t seem to get this working.

    I’m not sure I understand.

    If you have properly defined the metabox, you should be able to replace ‘gallery’ with ‘your_field_id’ and it should work.

    If you don’t define the size in the args, then it will by default grab the information for the thumbnail, as the documentation states:

    The information is attached with a specific image size, so don’t forget to add size=your_size in $args. Otherwise, you’ll get the infomation for thumbnail size.

    Thread Starter maestro_jules

    (@maestro_jules)

    Thanks for your quick response.

    This is the code in my functions.php:

    add_action( 'admin_init', 'rw_register_meta_box' );
        function rw_register_meta_box()
        {
        // Check if plugin is activated or included in theme
        if ( !class_exists( 'RW_Meta_Box' ) )
        return;
        $prefix = 'rw_';
        $meta_box = array(
        'id' => 'ministrylogo',
        'title' => 'Personal Information',
        'pages' => array( 'ministry_post'),
        'context' => 'normal',
        'priority' => 'high',
        'fields' => array(
        array(
        'name' => 'Ministry Logos',
        'type' => 'thickbox_image',
        ),
        )
        );
        new RW_Meta_Box( $meta_box );
        }

    I am trying to get image using the code below in my index.php:

    $images = rwmb_meta( 'ministrylogo', 'type=image' );
    foreach ( $images as $image )
    {
        echo "<a href='{$image['full_url']}' title='{$image['title']}' rel='thickbox'><img src='{$image['url']}' width='{$image['width']}' height='{$image['height']}' alt='{$image['alt']}' /></a>";
    }

    I also tried replacing the field name (ministrylogo) with “rw_ministrylogo” but still does not work.

    I really don’t know whats happening unless i am not doing the right thing.

    Your code doesn’t look like the complete code from the demo.php file.

    What I usually do for my custom metaboxes is the following:
    1. I copy the demo.php file from the demo folder of the plugin to an inc or lib directory in my theme
    2. I rename the file to something like cmb.php and add an include (or require) call to it in my functions.php file
    3. I then fill out the entire cmb.php file and delete the fields I do not need.
    4. if you then make the call from your template files, you will see that it works.

    This whole “procedure” is clearly described in the plugin’s documentation

    Thread Starter maestro_jules

    (@maestro_jules)

    Thanks. I’ll check it.

    Best Regards,
    Julius.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to retrieve meta data’ is closed to new replies.