Make WordPress Core

Opened 14 years ago

Closed 21 months ago

#11023 closed defect (bug) (worksforme)

Gallery Category Doesn't change with article

Reported by: mrgtb's profile mrgtb Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Gallery Keywords: has-patch
Focuses: Cc:

Description

Lets say I have a default category setup called Drafts that all articles go into at first by default. Then on completing the article before posting it live, I movie it to another category called News (no longer having the draft category ticked also). If I've added an image with that article that I click to view a bigger picture of in the gallery page (image.php). It still shows it as being listed under the Drafts category, while the article itself is listed under just News category.

Attachments (1)

11023.diff (762 bytes) - added by oso96_2000 10 years ago.

Download all attachments as: .zip

Change History (10)

#1 follow-up: @dd32
14 years ago

I believe this might be because uploads will ALWAYS recieve the default category, And never inherit the parents categories unless a plugin is used.. Just as you cant assign categories to uploads directly.

I do however agree, If an attachment is attached to a post, and %category% is used within the permalink, it should be that of the parent.

#2 @scribu
14 years ago

  • Milestone changed from Unassigned to 2.9

#3 @mrgtb
14 years ago

I see your point, Drafts is a parent category. While News is a Sub Category of Articles (Articles/News). So it looks like because I moved the articles from a default Top Category called Drafts to a sub category called Articles/News. This is why it's not updated.

OK, I'll, move the article to be included in both Articles/News or just Articles and see the difference

#4 @janeforshort
14 years ago

  • Milestone changed from 2.9 to Future Release

Punting, no patch.

This ticket was mentioned in IRC in #wordpress-dev by oso96_2000. View the logs.


10 years ago

@oso96_2000
10 years ago

#6 @oso96_2000
10 years ago

  • Keywords has-patch needs-testing added

Not sure if this would be the correct answer. In my tests I couldn't find that removing that condition causes problems and what it does is redirect the attachment page to the new one when a category is changed. If the attachment isn't attached to a post, it still uses the ?attachment_id=# page.

Of course, this only redirects, if the image is linked inside a post it still uses the old url.

#7 @oso96_2000
10 years ago

  • Keywords 2nd-opinion added

#8 @chriscct7
9 years ago

  • Keywords dev-feedback added; Gallery Category 2nd-opinion removed

#9 in reply to: ↑ 1 @desrosj
21 months ago

  • Keywords needs-testing dev-feedback removed
  • Resolution set to worksforme
  • Status changed from new to closed

It's been quite a while for this one.

I've done some testing and I think this can be closed out based on my findings.

Replying to dd32:

I believe this might be because uploads will ALWAYS recieve the default category, And never inherit the parents categories unless a plugin is used.. Just as you cant assign categories to uploads directly.

This doesn't seem to be the case anymore. Uploading an attachment to the media library (unattached) and having %category%/%postname% as the permalink structure results in a site.com/attachment-slug URL.

I do however agree, If an attachment is attached to a post, and %category% is used within the permalink, it should be that of the parent.

This now appears to be the default behavior.

To test:

  • Set custom permalink structure to anything using %category%. I used %category%/%postname%/.
  • Created a new category "Drafts"
  • Set the new category as the default.
  • Created a new post.
  • Inserted an image block and a gallery block and upload new images to each.
  • Changed both to link to the attachment page for the images.
  • Published.
  • The attachment page permalinks are /drafts/post-name/attachment/attachment-slug.
  • Change the parent post's category to Uncategorized (remove Drafts).
  • The attachment page permalinks become /uncategorized/post-name/attachment/attachment-slug.

Tested with both classic and block editors.

Note: See TracTickets for help on using tickets.