Nice RSS Feed URLs for each custom post type

By default WP seems to display all posts of all types in the main RSS feed.
You have to add a post_type query variable to show post of a certain type…

So how can I turn this:

Read More

http://site.com/feed/?post_type=book

into

http://site.com/feed/books/

?

And if possible rewrite http://site.com/feed/ to http://site.com/feed/blog/, which should display only normal posts…

Related posts

Leave a Reply

1 comment

  1. 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.