| 1 | Index: wp-includes/post-template.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/post-template.php (revision 19023) |
|---|
| 4 | +++ wp-includes/post-template.php (working copy) |
|---|
| 5 | @@ -11,23 +11,34 @@ |
|---|
| 6 | /** |
|---|
| 7 | * Display the ID of the current item in the WordPress Loop. |
|---|
| 8 | * |
|---|
| 9 | + * If the optional $id param is passed then this will simply display the $id. |
|---|
| 10 | + * |
|---|
| 11 | * @since 0.71 |
|---|
| 12 | + * |
|---|
| 13 | + * @param int $id Optional. Post ID. |
|---|
| 14 | */ |
|---|
| 15 | -function the_ID() { |
|---|
| 16 | - echo get_the_ID(); |
|---|
| 17 | +function the_ID( $id = 0 ) { |
|---|
| 18 | + echo get_the_ID( $id ); |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | /** |
|---|
| 22 | * Retrieve the ID of the current item in the WordPress Loop. |
|---|
| 23 | * |
|---|
| 24 | + * If the optional $id param is passed then this will simply return the $id. |
|---|
| 25 | + * |
|---|
| 26 | * @since 2.1.0 |
|---|
| 27 | * @uses $post |
|---|
| 28 | * |
|---|
| 29 | + * @param int $id Optional. Post ID. |
|---|
| 30 | * @return int |
|---|
| 31 | */ |
|---|
| 32 | -function get_the_ID() { |
|---|
| 33 | - global $post; |
|---|
| 34 | - return $post->ID; |
|---|
| 35 | +function get_the_ID( $id = 0 ) { |
|---|
| 36 | + if ( (int) $id > 0 ) { |
|---|
| 37 | + return $id; |
|---|
| 38 | + } else { |
|---|
| 39 | + global $post; |
|---|
| 40 | + return $post->ID; |
|---|
| 41 | + } |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | /** |
|---|