612-293-8629 HELLO@THEMIGHTYMO.COM
UPDATE: Please disregard this blog post. Ryan Duff gave me a huge tip that my code was not written correctly. In the code below, note that I have the line written as follows:
get_post_meta(post->ID, ‘custom_field_value’, true);
When you add the fancy dollar sign in front of “post->ID” like so “$post->ID”, the problem is fixed. Chalk it up to a late night bonehead move on my part, I guess. ūüôā

I ran into a problem this morning.

I was trying to use get_post_meta() within the loop and was unable to return the custom field value. ¬†The solution was to use “get_the_id()” rather than “post->ID” as shown below.

 

<del datetime="2011-09-11T00:45:21+00:00">$my_query = new WP_Query('showposts=1');
 
	while ($my_query->have_posts()) : $my_query->the_post();
 
		get_post_meta(get_the_id(), 'custom_field_value', true);  // This works!
 
		get_post_meta(post->ID, 'custom_field_value', true);  // This DOES NOT work!
 
	endwhile;</del>

Thanks to this post for providing the solution.

PHONE, EMAIL, TEXT

We love to communicate: phone, email, text, Facebook, Twitter, LinkedIn, you name it.

LOCATIONS

PAYMENTS ACCEPTED

Call Now

Enroll in Our Free Beginner WordPress Class - delivered to your Email Inbox!

Become a WordPress superstar for FREE in only minutes a day!  Our free Beginner WordPress Email Class will be delivered to your inbox!

Learn More 

You Have Successfully Enrolled! Prepare For Amazing!