From c24de5caf84c0c104e1f34609de468bf11961d9b Mon Sep 17 00:00:00 2001 From: westi Date: Thu, 6 May 2010 21:20:17 +0000 Subject: [PATCH] Make wp_get_shortlink() loop friendly. Fixes #13212 props ryan. git-svn-id: http://svn.automattic.com/wordpress/trunk@14490 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/link-template.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 62afd9d93..d76e34c1c 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -2172,10 +2172,12 @@ function wp_get_shortlink($id = 0, $context = 'post', $allow_slugs = true) { global $wp_query; $post_id = 0; - if ( 'query' == $context && is_single() ) + if ( 'query' == $context && is_single() ) { $post_id = $wp_query->get_queried_object_id(); - elseif ( 'post' == $context ) - $post_id = $id; + } elseif ( 'post' == $context ) { + $post = get_post($id); + $post_id = $post->ID; + } $shortlink = '';