Ticket #4699 (closed defect: fixed)

Opened 9 months ago

Last modified 2 months ago

Custom Permalinks Containing Categories Are Broken for Attachments

Reported by: mtekk Assigned to: markjaquith
Priority: normal Milestone: 2.5
Component: General Version: 2.2.1
Severity: blocker Keywords: attachment, permalink, category
Cc:

Description

Currently, with WordPress 2.2.1, when using a custom permalink structure containing the %category% tag, permalinks to attachment posts become broken. It seems to have something to do with the attachments having no category and thus cause the link to become broken.

Using the permalink scheme /archives/%category%/%postname%/ an example attachment 'bar' attached to the post 'foo' which happens to be in the general category results in the following broken permalink http://sitename.com/archives/general/foo/bar/. The permalink makes sense, but doesn't work due to the attachment post not inheriting the category(ies) of the post it is attached to.

Attachments

category_permastruct_attachment.diff (1.2 kB) - added by ryan on 03/21/08 05:33:24.
4699-rule-order.diff (0.9 kB) - added by andy on 03/26/08 20:13:38.
put explicit rules first

Change History

08/04/07 01:50:49 changed by markjaquith

  • owner changed from anonymous to markjaquith.
  • status changed from new to assigned.
  • milestone set to 2.4 (future).

We're forcing %postname% (post slug) to be unique anyway, so we should probably just drop %category% from the query if %postname% is present. Actually, if %postname% is present, we can probably drop all other params.

(follow-up: ↓ 3 ) 08/21/07 00:57:45 changed by hakre

what about comparing from left to right?

(in reply to: ↑ 2 ) 08/21/07 01:10:38 changed by DD32

Replying to hakre:

what about comparing from left to right?

Thats not really a great fix, what if i used this as my permalink structure:

/archives/%postname%/%category%/

Ok its Unlikely someone would use that structure, but it shows that a left to right compare is just as useless

If we're forcing ALL post slugs to be unique, then to simplify it i'd agree that if %post_id% or %postname% is available(In that order) then it should ignore any other post-selectors in the url.

03/19/08 21:29:50 changed by lloydbudd

#6299 Gallery Permalinks using /%category%/%postname%/ return 404
was closed as a duplicate of this ticket.

03/20/08 18:23:35 changed by matt

  • severity changed from normal to blocker.

03/20/08 19:47:55 changed by ryan

Even if you skip the category_name query whenever the request is_singular, the permalink will break because %category% gobbles up slashes and prevents the rewrite rules from recognizing the attachment. Instead of doing an attachment query, a post query is done. We'd have to change single post queries to look for both posts and attachments.

03/21/08 03:25:34 changed by ryan

Creating explicit attachment links as in #6280 might help.

03/21/08 04:18:13 changed by markjaquith

I like the explicit attachment links idea. Also prevents the "feed.jpg" issue, if we weren't already dealing with that.

03/21/08 05:33:24 changed by ryan

  • attachment category_permastruct_attachment.diff added.

03/21/08 05:38:34 changed by ryan

That patch gets us part of the way there, but the attachment rewrite rules aren't ordered early enough to prevent the category regex from claiming attachment as part of the category name.

03/26/08 20:13:38 changed by andy

  • attachment 4699-rule-order.diff added.

put explicit rules first

03/26/08 20:17:36 changed by ryan

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [7531]) Fix attachment links for permalink structures containing category tag. Props andy. fixes #4699