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
Make WordPress Work for You: How to turn your self-hosted WordPress blog into a totally rocking Content Management System (CMS)
WordPress Presentation What we might cover How many people have a website or blog? Brainstorm ideas for websites. What do you want your website to do? WordPress as a CMS Examples: GBSSA.org, TeamUpMn.org, Letronica.com (http://www.letronica.com/content/), cryns.com Switching WordPress from a Blog to a CMS Photo Gallery: http://www.cryns.com/category/photos/ Post by email iPhone Application Cool Plugins: Podpress…
Mark Gason Papervision 3D Presentation at FlashMN
I am liveblogging from Mark Gason’s presentation at FlashMN. These are my notes. Check out Mark’s page of resources. It contains links to tutorials as well as all sorts of other Papervision 3D-related stuff. http://gasolicious.com/flashstuff/PV3D_presentation.html Swift 3D is better than Papervision 3D in some ways: – You can model in Swift 3D, but AutoCAD also…