| 1 | /** |
|---|
| 2 | * Get a blog post metadata from any site on the network. |
|---|
| 3 | * |
|---|
| 4 | * @param int $blog_id ID of the blog. |
|---|
| 5 | * @param int $post_id ID of the post. |
|---|
| 6 | * @param string $meta_key you're looking for. |
|---|
| 7 | * @return object The metadata. |
|---|
| 8 | **/ |
|---|
| 9 | function get_blog_metadata( $blog_id, $post_id, $meta_key ) { |
|---|
| 10 | global $wpdb; |
|---|
| 11 | |
|---|
| 12 | $key = $blog_id . '-' . $post_id; |
|---|
| 13 | $postmeta = wp_cache_get( $key, 'global-postmeta-'.$meta_key ); |
|---|
| 14 | if ( $postmeta == false ) { |
|---|
| 15 | $postmeta = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . $wpdb->get_blog_prefix( $blog_id ) . 'postmeta WHERE post_id = %d AND meta_key = %s', $post_id, $meta_key ) ); |
|---|
| 16 | wp_cache_add( $key, $postmeta, 'global-postmeta-'.$meta_key ); |
|---|
| 17 | } |
|---|
| 18 | |
|---|
| 19 | return $postmeta; |
|---|
| 20 | } |
|---|