| 1 | Index: wp-includes/query.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/query.php (revision 6372) |
|---|
| 4 | +++ wp-includes/query.php (working copy) |
|---|
| 5 | @@ -841,6 +841,12 @@ |
|---|
| 6 | $q['pagename'] = sanitize_title(basename($page_paths)); |
|---|
| 7 | $q['name'] = $q['pagename']; |
|---|
| 8 | $where .= " AND (ID = '$reqpage')"; |
|---|
| 9 | + $reqpage_obj = get_page($reqpage); |
|---|
| 10 | + if ( 'attachment' == $reqpage_obj->post_type ) { |
|---|
| 11 | + $this->is_attachment = true; |
|---|
| 12 | + $this->is_page = false; |
|---|
| 13 | + $q['attachment_id'] = $reqpage; |
|---|
| 14 | + } |
|---|
| 15 | } |
|---|
| 16 | } elseif ('' != $q['attachment']) { |
|---|
| 17 | $q['attachment'] = str_replace('%2F', '/', urlencode(urldecode($q['attachment']))); |
|---|
| 18 | Index: wp-includes/post.php |
|---|
| 19 | =================================================================== |
|---|
| 20 | --- wp-includes/post.php (revision 6372) |
|---|
| 21 | +++ wp-includes/post.php (working copy) |
|---|
| 22 | @@ -976,7 +976,7 @@ |
|---|
| 23 | foreach($page_paths as $pathdir) |
|---|
| 24 | $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir); |
|---|
| 25 | |
|---|
| 26 | - $pages = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = %s AND post_type='page'", $leaf_path )); |
|---|
| 27 | + $pages = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = %s AND (post_type = 'page' OR post_type = 'attachment')", $leaf_path )); |
|---|
| 28 | |
|---|
| 29 | if ( empty($pages) ) |
|---|
| 30 | return NULL; |
|---|