I have been trying out the custom post types for WordPress 3.0 Beta 2, I ran into a problem where i could not call the custom fields for posts i have assigned custom post type values.
I came up with this workaround for now until it is sorted.
function get_post_meta_custom($key, $single = false) { global $wpdb,$post; $answer = $wpdb->get_var($wpdb->prepare("SELECT meta_value FROM $wpdb->postmeta WHERE post_id = ".$post->ID." AND meta_key = '".$key."'")); return $answer; }
Call it using the following. I use this inside on the single post inside the loop.
if ( get_post_meta_custom('client_name', true) ) {echo get_post_meta_portfolio('client_name', true); }
Leave a Reply