Make WordPress Core

Opened 14 years ago

Closed 8 years ago

#12943 closed feature request (worksforme)

Feeds for custom post types

Reported by: matthewhollett's profile matthewhollett Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Feeds Keywords:
Focuses: Cc:


Right now, there is no easy way to get a feed that includes custom post types. The RSS Includes Pages plugin by Marios Alexandrou modifies feeds to include pages, and could easily be updated to apply to other post types. Perhaps this functionality could be included in core.

Change History (9)

#1 @rovo89
14 years ago

  • Cc wordpress@… added
  • Keywords feeds rss custom post types removed

If you want to have a feed for only one custom post type, that's easy: Simply use

Queries for multiple post types at once are supported internally, however all request parameters are converted to strings by this line: Otherwise you could probably use something like[]=yourposttype1&post_type[]=yourposttype2.

#2 @matthewhollett
14 years ago

Thanks, I hadn't realized you could get a feed for a single post type like that. A way to query multiple post types just as easily would be super useful.

#3 @rovo89
14 years ago

Using this in a plugin, the default feed will return the posts of all types:

function myfeed_request($qv) {
	if (isset($qv['feed']))
		$qv['post_type'] = get_post_types();
	return $qv;
add_filter('request', 'myfeed_request');

If you use it like that, the post_type parameter in the URL will be ignored, so you might want to add && !isset($qv['post_type']). Also, get_post_types() can be called with attributes that the post type needs have, such as publicly_queryable => true. Or you could use a hardcoded list. Or only apply the filter if some special GET parameter was passed. Or... ;)

#4 @scribu
14 years ago

  • Milestone 3.0 deleted
  • Resolution set to worksforme
  • Status changed from new to closed

As rovo89 proved, this can be done easily enough already.

#5 @matthewhollett
14 years ago

Thanks, that works perfectly, and will be very useful for a couple of projects I'm working on.

#6 @nacin
14 years ago

Careful with that code snippet above -- get_post_types() should be get_post_types( array( 'public' => true ) ), if not a very specific whitelist (for example menu items are public = true).

#7 @nacin
13 years ago

menu items are no longer public => true.

#8 @hmbashar
8 years ago

  • Keywords needs-screenshots needs-docs added
  • Resolution worksforme deleted
  • Status changed from closed to reopened

How can i use 4.4.1 version? maybe 4.4 has been updated get_post_types function. please me. i have custom post in my portfolio website custom post name is portfolios but i can't get rss feed url.

#9 @SergeyBiryukov
8 years ago

  • Keywords needs-screenshots needs-docs removed
  • Resolution set to worksforme
  • Status changed from reopened to closed

Hi @hmbashar,

Please try the support forums to get help with your site:

Note: See TracTickets for help on using tickets.