How can I display my custom metaboxes on a custom post template?

I’m fairly new to PHP/wordpress, and this is actually the first time I haven’t been able to answer a question through google! I’m working on getting up to speed with PHP/WP generally, but I can’t seem to learn fast enough to keep up with what we need to accomplish already. Please have patience with my ignorance. I’d appreciate any advice, or a push in the right direction.

Basically, I’ve followed a number of tutorials, and used Jared Datch’s CMB script to accomplish a custom post type (‘report’) that now contains a series of metaboxes, a custom taxonomy, and custom capabilities that allow users of a specific role to access only this post type. Everything looks as it should at the WP back-end (for now)– data from the boxes is being saved and retrieved property, etc.

http://pastebin.com/Ba82Fzbs

I then created a single-report.php template, followed by a content-report.php template (I am using a twentytwelve child theme), and as I understand it, I need to do something in the content-report.php template to display the information from the custom metaboxes on the individual pages.

I want to display all the metaboxes associated with my custom post type ‘report’ in a way that will allow further styling/arrangement. So far, I’ve experimented with do_meta_boxes() and get_post_meta() and I think I just am not understanding the proper usage of either in a very fundamental way, because none of the information displays.

I believe get_post_meta() will give me what I need (the ability to echo data from individual metaboxes so that I can arrange it) and this is how I inserted it into my page template:

    <?php get_post_meta( get_the_ID(), 'date-time');
echo get_post_meta( get_the_ID(), 'date-time'); ?>

Which displays nothing but “array” in that spot when viewed from the front-end. I have had the same problem with my “practice” versions of custom post types and metaboxes, so I’m assuming it’s more than a typo– that I’m missing something very basic.

I would very much appreciate any help with this, and thank you kindly for even reading this far!

Solutions Collecting From Web of "How can I display my custom metaboxes on a custom post template?"

Looking at your code, it appears all meta keys are prefixed with _cmb_. Your start time key is text_datetime_timestamp, so combined with the prefix, you want to fetch:

get_post_meta( get_the_ID(), '_cmb_text_datetime_timestamp', true );

Note the third parameter, which will retrieve a single value if set to true, as it’s possible to save multiple values under a single key, which would result in an array of values.

The simplest way to see all of the keys your meta data is saved under, is via get_post_custom_keys:

$custom_field_keys = get_post_custom_keys();
foreach( $custom_field_keys as $key => $value ) {
    echo $key . " => " . $value . "<br />";
}

Put that in the loop and it will tell you the names of all of the keys your meta data is saved under.