Query page attachments from page requests so that they can both use the same set of rewrite rules. see #3614

git-svn-id: http://svn.automattic.com/wordpress/trunk@6377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-12-12 11:45:55 +00:00
parent 805e41198c
commit f0a47b7127
2 changed files with 7 additions and 1 deletions

View File

@ -976,7 +976,7 @@ function get_page_by_path($page_path, $output = OBJECT) {
foreach($page_paths as $pathdir)
$full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
$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 ));
$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 ));
if ( empty($pages) )
return NULL;

View File

@ -841,6 +841,12 @@ class WP_Query {
$q['pagename'] = sanitize_title(basename($page_paths));
$q['name'] = $q['pagename'];
$where .= " AND (ID = '$reqpage')";
$reqpage_obj = get_page($reqpage);
if ( 'attachment' == $reqpage_obj->post_type ) {
$this->is_attachment = true;
$this->is_page = false;
$q['attachment_id'] = $reqpage;
}
}
} elseif ('' != $q['attachment']) {
$q['attachment'] = str_replace('%2F', '/', urlencode(urldecode($q['attachment'])));