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

Kevinjohn Gallagher kevinjohngallagher at hotmail.com
Mon Jul 2 23:09:37 UTC 2012



Hi Paul,
Rules are loaded as an array, so you can "unset" them from the array.
2 points to note. 
You then need to flush the rules.If a theme or plugin flushes rules every time they are loaded (99% do - sigh) then you'll need to do so as well.
If you're in no rush I can look out my code tomorrow afternoon.
Kev



> Date: Mon, 2 Jul 2012 23:11:33 +0100
> From: paul at byotos.com
> To: wp-hackers at lists.automattic.com
> Subject: [wp-hackers] how to stop custom post type creating attachment/trackback/feed rewrite rules?
> 
> 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
> 
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
 		 	   		  


More information about the wp-hackers mailing list