| | 657 | * Retrieve a single post meta value. |
| | 658 | * |
| | 659 | * @since 3.1.0 |
| | 660 | * |
| | 661 | * @uses get_post_meta |
| | 662 | * |
| | 663 | * @param string $field The name of the custom field for which we'll retrieve the value. |
| | 664 | * @param int $post_id Optional. The ID of the post object with which this custom field is associated. Defaults to current Loop object or queried object. |
| | 665 | * @return mixed The custom value retrieved. |
| | 666 | */ |
| | 667 | function get_custom_value( $field = '', $post_id = 0 ) { |
| | 668 | global $wp_query; |
| | 669 | |
| | 670 | $post_id = (int) $post_id; |
| | 671 | if ( empty( $post_id ) ) |
| | 672 | $post_id = (int) get_the_ID(); |
| | 673 | |
| | 674 | if ( empty( $post_id ) && is_singular() ) |
| | 675 | $post_id = (int) $wp_query->get_queried_object_id(); |
| | 676 | |
| | 677 | return get_post_meta( $post_id, $field, true ); |
| | 678 | } |
| | 679 | |
| | 680 | |
| | 681 | /** |