I have a custom field for my post and I am trying to output it onto my post's page but nothing appears. I know my code works otherwise if instead of trying to call my custom field, I use a fixed string.
My custom field key has an id of
_dad_wysiwyg
I am using this to try to display the value of the key from within functions.php:
add_action( '__after_content' , 'add_dad_cents' );
function add_dad_cents() {
echo get_post_meta($post->ID, '_dad_wysiwyg', true);
}
I know the key has a value by looking at my postmeta table in my database. The value of the key is
<p>test</p>
Logically, after my post content, I'd expect to see the above string but nothing appears. As I stated, if I change my function to echo a string, I see the string where expected after my post content.
edit: It appears $post is empty. Clearly, I need help calling the post ID from functions.php...
Can anyone help me figure out how to call the value?
Thanks!
$post
inside your function? – Milo Jun 6 '14 at 17:22