diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 4264d784ef..9ba51f4e1d 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -2417,7 +2417,8 @@ function wp_get_shortlink($id = 0, $context = 'post', $allow_slugs = true) { $post = get_post( $post_id ); } elseif ( 'post' == $context ) { $post = get_post( $id ); - $post_id = $post->ID; + if ( ! empty( $post->ID ) ) + $post_id = $post->ID; } $shortlink = '';