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


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


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?


  • 1
    What is the value of $post inside your function?
    – Milo
    Commented Jun 6, 2014 at 17:22
  • $post would appear to be empty. Clearly this is the source of my problem. How do I get the post ID if the function is inside functions.php?
    – Sweepster
    Commented Jun 6, 2014 at 21:55

1 Answer 1


Problem solved.

Added the following to my function:

global $post;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.