You’re using $post->ID
, but haven’t defined $post
anywhere. You either need to specify global $post;
, to get the current post in the loop, or define it some other way. But the best way to get this ID would just be to use get_the_ID()
:
<?php $sub_heading = get_post_meta( get_the_ID(), 'sub_heading', true ); ?>