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
I added the following functionality to The Mighty Moo! WordPress theme: Custom stylesheet class example Basically, what I did was add an example to the custom stylesheet to get you rolling. 🙂
Today, I spent eight hours making a number of significant updates to The Mighty Moo! WordPress theme. This set of updates increases the version number to 1.2.2. and include: Single Page template Comment Threading Fixed Commenting bug Custom Style Sheet (Upgrades now won’t mess up your custom CSS edits!) The next round of updates will…