WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question
What is the value of $post inside your function? – Milo Jun 6 '14 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 Jun 6 '14 at 21:55
up vote 1 down vote accepted

Problem solved.

Added the following to my function:

global $post;
share|improve this answer
please accept your answer so it's marked as solved :) – Tim Malone Jun 30 at 1:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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