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.
$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;
Thanks to this post for providing the solution.
More posts from themightymo.com
Reorganize Your WordPress 2.7 Admin Panel with Fluency 2.0
Yesterday I discovered the new Fluency 2.0 plugin for WordPress 2.7. It does a fantastic job of cleaning up the admin interface and makes the back-end WordPress experience much better for users.
We Now Offer Search Engine Optimization!
We have just teamed up with one of the web’s finest search engine optimization gurus, Greg Cryns, and will now be offering his services to you, our customers! For you, our customer, this means that we now have added expertise in driving targeted traffic to your website. Greg has over a decade worth of search…
Adobe CS4 Flash MN Presentation at FlashMN
Below are my notes from tonight’s FlashMN meeting starring Dustin Tauer. The presentation focused on the new features of Adobe Creative Suite 4. Illustrator CS4 Can create multiple art boards. So, if I wanted to use artwork for the front and back of t-shirt, I would create 2 art boards (up to 100). There are…