Nice RSS Feed URLs for each custom post type

If you set 'has_archive' => TRUE in register_post_type() the post type will have its own feed on /books/feed/ and its items are not included in the main feed.

Example plugin

<?php
/*
Plugin Name: WPSE13006 feed for CPT demo
*/
! defined( 'ABSPATH' ) and exit;

add_action( 'init', 'wpse13006_register' );

// Call wp-admin/options-permalink.php once after activation to make permalinks work
function wpse13006_register()
{
    register_post_type(
        'wpse13006'
    ,   array (
            'has_archive'         => TRUE
        ,   'label'               => 'wpse13006'
        ,   'public'              => TRUE
        ,   'publicly_queryable'  => TRUE
        ,   'query_var'           => 'wpse13006'
        ,   'rewrite'             => array ( 'slug' => 'wpse13006' )
        ,   'show_ui'             => TRUE
        ,   'show_in_menu'        => TRUE
        ,   'supports'            => array ( 'title', 'editor' )
        )
    );
}

Create one post, publish and view it. If you go up one level to /wpse13006/ now, you’ll find the feed at /wpse13006/feed/. The post will not show up in the main feed.

Leave a Comment