diff --git a/wp-includes/template-functions-links.php b/wp-includes/template-functions-links.php
index e22d4b777e..d5dfc52304 100644
--- a/wp-includes/template-functions-links.php
+++ b/wp-includes/template-functions-links.php
@@ -208,13 +208,18 @@ function get_feed_link($feed='rss2') {
function edit_post_link($link = 'Edit This', $before = '', $after = '') {
global $post;
- if ( ! current_user_can('edit_post', $post->ID) )
- return;
-
if ( is_attachment() )
return;
- else
+
+ if( $post->post_type == 'page' ) {
+ if ( ! current_user_can('edit_page', $post->ID) )
+ return;
+ $file = 'page';
+ } else {
+ if ( ! current_user_can('edit_post', $post->ID) )
+ return;
$file = 'post';
+ }
$location = get_settings('siteurl') . "/wp-admin/{$file}.php?action=edit&post=$post->ID";
echo $before . "$link" . $after;
@@ -223,10 +228,14 @@ function edit_post_link($link = 'Edit This', $before = '', $after = '') {
function edit_comment_link($link = 'Edit This', $before = '', $after = '') {
global $post, $comment;
- if ( ! current_user_can('edit_post', $post->ID) )
- return;
+ if( $post->post_type == 'page' )
+ if ( ! current_user_can('edit_page', $post->ID) )
+ return;
+ else
+ if ( ! current_user_can('edit_post', $post->ID) )
+ return;
- $location = get_settings('siteurl') . "/wp-admin/post.php?action=editcomment&comment=$comment->comment_ID";
+ $location = get_settings('siteurl') . "/wp-admin/comment.php?action=editcomment&comment=$comment->comment_ID";
echo $before . "$link" . $after;
}