[wp-hackers] how to stop custom post type creating attachment/trackback/feed rewrite rules?

Paul Gibbs paul at byotos.com
Mon Jul 2 22:11:33 UTC 2012


When registering a custom post type ("achievements") with the following arguments, WordPress creates more rewrite rules than I want. My concern is causing the unnecessary rules to be generated, and the possibility of a theme's generic template files being used. For example, I don't want any feed for my post type, but right now I can type the URL in and get fetch a RSS feed. I'm on WP 3.4.

How do I stop these rules being generated?


// 'rewrite'
$rewrite['achievement'] = array(
'feeds'      => false,
'pages'      => false,
'slug'       => dpa_get_achievement_slug(),
'with_front' => false,
);
// 'supports'
$supports['achievement'] = array(
'editor',
'revisions',
'thumbnail',
'title',
);


Using the Rewrite Rules Inspector plugin, I see WordPress has generated the following rewrite rules which I do not require:

ATTACHMENTS + COMMENT PAGING:
achievements/.+?/attachment/([^/]+)
achievements/.+?/attachment/([^/]+)/trackback/?$
achievements/.+?/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$
achievements/.+?/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$
achievements/.+?/attachment/([^/]+)/comment-page-([0-9]{1,})/?$

TRACKBACK + FEED + COMMENT PAGING:
achievements/(.+?)/trackback/?$
achievements/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$
achievements/(.+?)/(feed|rdf|rss|rss2|atom)/?$
achievements/(.+?)/comment-page-([0-9]{1,})/?$

-- 
Paul Gibbs



More information about the wp-hackers mailing list