Fix attachment links for permalink structures containing category tag. Props andy. fixes #4699

git-svn-id: http://svn.automattic.com/wordpress/trunk@7531 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-03-26 20:17:31 +00:00
parent f0a9ece115
commit bba593e250
3 changed files with 3 additions and 3 deletions

View File

@ -179,7 +179,7 @@ function get_attachment_link($id = false) {
$parentlink = _get_page_link( $object->post_parent ); // Ignores page_on_front $parentlink = _get_page_link( $object->post_parent ); // Ignores page_on_front
else else
$parentlink = get_permalink( $object->post_parent ); $parentlink = get_permalink( $object->post_parent );
if ( ctype_digit($object->post_name) ) if ( ctype_digit($object->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )
$name = 'attachment/' . $object->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker $name = 'attachment/' . $object->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker
else else
$name = $object->post_name; $name = $object->post_name;

View File

@ -1036,7 +1036,7 @@ class WP_Query {
} }
// Category stuff for nice URLs // Category stuff for nice URLs
if ( '' != $q['category_name'] ) { if ( '' != $q['category_name'] && !$this->is_singular ) {
$reqcat = get_category_by_path($q['category_name']); $reqcat = get_category_by_path($q['category_name']);
$q['category_name'] = str_replace('%2F', '/', urlencode(urldecode($q['category_name']))); $q['category_name'] = str_replace('%2F', '/', urlencode(urldecode($q['category_name'])));
$cat_paths = '/' . trim($q['category_name'], '/'); $cat_paths = '/' . trim($q['category_name'], '/');

View File

@ -765,7 +765,7 @@ class WP_Rewrite {
//add regexes/queries for attachments, attachment trackbacks and so on //add regexes/queries for attachments, attachment trackbacks and so on
if ( ! $page ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages if ( ! $page ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages
$rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery)); $rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery));
$rewrite = array_merge($rewrite, array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery)); $rewrite = array_merge(array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery), $rewrite);
} }
} //if($num_toks) } //if($num_toks)
//add the rules for this dir to the accumulating $post_rewrite //add the rules for this dir to the accumulating $post_rewrite