How can we disable a custom post type archive page but enable its feed?

To disable a custom post types archive page, we should use the following code:

$args = array(
    'has_archive' => false,
);

But when we use false for has_archive, the feeds page (like : name.com/books/feed) of that custom post type becomes disabled too. Now I want to know how I can disable custom post types archive page but keep the feed active?

2 Answers
2

Set the feeds argument of rewrite to true to generate feed rewrite rules. It defaults to whatever has_archive is set to if nothing is explicitly passed.

$args = array(
    'has_archive' => false,
    'rewrite' => array(
        'feeds' => true
    ),
    // your other args...
);

Leave a Comment