Site icon Hip-Hop Website Design and Development

get_post_meta($post->ID) returns empty string when in preview mode of custom post type

I’ve got my custom post type ‘event’. I got tne next code in single-event.php:

get_header();
the_post();
echo '<pre>';
echo "$post->IDn";
var_dump(get_post_meta($post->ID));
echo '</pre>';

When I open my event page by normal URI /event/slug/, I got this:

22681
array(17) {
  ["_edit_lock"]=>
  array(1) {
    [0]=>
    string(13) "1439329938:36"
  }
  ["_edit_last"]=>
  array(1) {
    [0]=>
    string(2) "36"
  }
...
}

When I open it for preview, like /event/slug/?preview=true&preview_id=22681&preview_nonce=XXXXXXXXXXXXX , I got only this:

22681
string(0) ""

(where first line is a correct post ID and is the same as preview_id param)

What am I doing wrong? And why string(0), and not array(0)?