$post->ID
is what makes the meta value distinguished across all posts with the same meta key.
So if you want to shorthand the get_post_meta
call for the current post you can do this:
function get_cuurent_post_meta($key){
global $post;
return get_post_meta($post->ID,$key,true);
}
and you can call it like this:
echo get_cuurent_post_meta('custom_tags'.$userID);
Now if its not the current post but any post you can do this:
function get_meta_value_by_key($meta_key,$limit = 1){
global $wpdb;
if (1 == $limit)
return $value = $wpdb->get_var( $wpdb->prepare("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = %s LIMIT 1" , $meta_key) );
else
return $value = $wpdb->get_results( $wpdb->prepare("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = %s LIMIT %d" , $meta_key,$limit) );
}
to get the first meta value of this key just call it like this:
echo get_meta_value_by_key('custom_tags'.$userID);
and to get all meta values of this key use the $limit
param ex:
$post_meta_array = get_meta_value_by_key('custom_tags'.$userID, 999);