WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 7 months ago

#16415 new enhancement

Don't require CPTs to have archives in order to have feeds

Reported by: aaroncampbell Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.1
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:

Description

When archives and feeds were added to custom post types (see #13818) it was set up so you had to have archives (has_archive) in order to have feeds (rewrite[feeds]).

There are some situations where it would be nice to have feeds but archives aren't needed.

Attachments (6)

16415.diff (2.1 KB) - added by aaroncampbell 3 years ago.
16415.2.diff (2.4 KB) - added by SergeyBiryukov 21 months ago.
16415.3.diff (3.6 KB) - added by aaroncampbell 19 months ago.
16415.4.diff (3.7 KB) - added by aaroncampbell 19 months ago.
16415.5.diff (3.8 KB) - added by aaroncampbell 19 months ago.
16415.6.diff (4.0 KB) - added by wonderboymusic 9 months ago.

Download all attachments as: .zip

Change History (26)

aaroncampbell3 years ago

comment:1 scribu3 years ago

  • Keywords 2nd-opinion added

Could you give an example of such a situation?

comment:2 follow-up: markmcwilliams3 years ago

You would still need to use the has_archive though Aaron (even with your patch), unless I'm hugely mistaken? Take site.com/cpt-archive/feed/ for example, which gives you what it does currently, where would the /feed/ be if there was no archives? Or have I still missed something?

Unless you're on about doing site.com/cpt-rewrite-slug/feed/ if I follow?

comment:3 in reply to: ↑ 2 ; follow-up: aaroncampbell3 years ago

@scribu:
Sorry, I explained it all to Nacin but didn't get it into the ticket because it seemed long winded. The quick example is my beer review site. It has two CPTs...beer and beer-review. I'd like to have a feed for beer-review. Something that other sites could consume and show the kind of activity on my site. However, having an archive page of reviews for all different beer reviews really doesn't make any sense because they're just too random (however, I do have an archive page for beers).

The quick solution for me is to turn on archives for both and redirect the beer-review archives to the beer archives, but the correct solution is to allow feeds without archives.

The other oddity is the slugs. If the feed is at /beer-review/feed/ and you remove feed/ you'll get a 404 if there's no archive. However, if there's no archive the same is true of each review which would look like /beer-review/my-beer-review-slug/

@markmcwilliams: I tested it on trunk at the #wcphx dev day and it worked without has_archive. If you don't specify a has_archive slug it uses the rewrite slug.

comment:4 nacin3 years ago

  • Keywords 2nd-opinion removed

Keep in mind we originally just supported /slug/post-slug/, not /slug/. Allowing /slug/feed/ even when not supporting /slug/ makes more sense in that context.

I spoke with aaron and agreed this would be a nice enhancement. Better to be as flexible as people want when it's easy to introduce it.

comment:5 in reply to: ↑ 3 markmcwilliams3 years ago

Replying to aaroncampbell:

@markmcwilliams: I tested it on trunk at the #wcphx dev day and it worked without has_archive. If you don't specify a has_archive slug it uses the rewrite slug.

So I really ended up answering my own question! ;) And from that point of view (while I don't have a use for just the feed yet) it would be handy, like Nacin says.

comment:6 aaroncampbell21 months ago

  • Keywords commit added
  • Milestone changed from Future Release to 3.5

SergeyBiryukov21 months ago

comment:7 follow-up: SergeyBiryukov21 months ago

Refreshed the patch (16415.diff didn't apply cleanly).

Version 0, edited 21 months ago by SergeyBiryukov (next)

comment:8 in reply to: ↑ 7 aaroncampbell21 months ago

Replying to SergeyBiryukov:

Refreshed the patch (16415.diff didn't apply cleanly).

Thanks Sergey, it was on my TODO list but I hadn't got there yet. Looks good.

comment:9 nacin19 months ago

Seems like get_post_type_archive_feed_link() needs a modification.

aaroncampbell19 months ago

comment:10 aaroncampbell19 months ago

16415.3.diff fixes get_post_type_archive_feed_link() for post types with feeds and no archive.

aaroncampbell19 months ago

comment:11 aaroncampbell19 months ago

16415.4.diff only adds/removes the filter if it isn't already there.

aaroncampbell19 months ago

comment:12 aaroncampbell19 months ago

16415.5.diff switches the filter to ignore_has_archive_$post_type which is better worded and allows you to pass a more logical __return_true to override.

comment:13 follow-up: nacin18 months ago

  • Keywords 3.6-early added
  • Milestone changed from 3.5 to Future Release

I have some ideas here. Punting as this can be done by manually adding rules for now.

comment:14 helen16 months ago

  • Milestone changed from Future Release to 3.6

comment:15 sabreuse15 months ago

  • Cc sabreuse added

comment:16 ryan11 months ago

  • Milestone changed from 3.6 to Future Release

comment:17 aaroncampbell11 months ago

I see that we punted this one again, which is fine, but I'm wondering what nacin's ideas were regarding this. I'd like to see this addressed in the near future, so if there's something I can do to help that happen let me know.

wonderboymusic9 months ago

comment:18 wonderboymusic9 months ago

  • Milestone changed from Future Release to 3.7

Patch was failing against trunk, refreshed

comment:19 desrosj8 months ago

  • Cc desrosj@… added

comment:20 in reply to: ↑ 13 jeremyfelt7 months ago

  • Keywords commit 3.6-early removed
  • Milestone changed from 3.7 to Future Release

Replying to nacin:

I have some ideas here. Punting as this can be done by manually adding rules for now.

Punting this to future release as there seems to be some outstanding thoughts on approach.

Note: See TracTickets for help on using tickets.