Feeds for Custom Content Types

You can use the pre_get_posts() filter to include custom content types in feeds as well as the home page. The required change is shown in Listing 12-20.

Listing 12-20. Showing the course content type alongside posts in the site feed add_filter( 'pre_get_posts', 'my_get_posts' );

$query->set( 'post_type', array( 'post', 'course' ) ); return $query;

However, for the Honors office, it would make more sense to separate the courses from the posts feed, which is used for office news.

As you saw in Chapter 4, there are many feeds that aren't publicized in WordPress. You can use a query string format similar to the one you used for searches to get feeds of your custom content types. The post_type parameter given should match the name of your custom content type. You can even combine content types using the parameters instead of filters. Table 12-1 lists some of the possible feed URLs for custom content types.

Table 12-1. Course content type feeds in WordPress

Feed Type

Default URL

Clean URL

RSS 2.0 (default)

Atom 1.0

RSS 0.92

Combining content types





/feed/?post_type=course /feed/rss2/?post_type=course




/?feed=rss2&post_type=course,post,page /feed/?post_type=course,post,page

Was this article helpful?

0 0

Post a comment