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 just updated our Simple Pull Quote WordPress plugin to include an external style sheet that you can edit. The plugin is simple and completely customizable via CSS. It uses shortcode and custom fields that make it easy to control where the pull quotes will go.
Tonight, I will be teaching a class for folks who are interested in learning more about blogging. The class, titled PC Web Blogging for Beginners, is offered at Minneapolis’ Washburn High School via Minneapolis Community Education‘s Adult Enrichment program. Anyone can register for only $15. I am excited to be participating in this exciting venture! …
I discovered today that there is not a pull quote plugin for WordPress that does what I would like it to do. So, I have begun developing one myself. This is my first attempt at a plugin, and so far it has been a great learning experience (read: lots and lots of failures). haha! I…