[wp-hackers] Make WP_Rewrite eaiser to use

Sam Angove sam at rephrase.net
Mon Feb 6 09:31:34 GMT 2006


On 2/6/06, Peter Westwood <peter.westwood at ftwr.co.uk> wrote:
>
> This will work _except_ for feeds.  The rewrite rules for feeds expect
> the feed_base to be feed and don't match when it is changed - you end up
> with the feed links 404'ing.

Hmm, I see what you mean. Though I'm more inclined to say that
get_feed_link() is broken if the feed is RSS2. Of course, you can
always work around it... ;)

function fix_broken_get_feed_link($rules) {
	global $wp_rewrite;
	$base = $wp_rewrite->feed_base;
	$comment_base = $wp_rewrite->comments_base;
	$rules["$base/?"] = 'index.php?feed=rss2';
	$rules["$comment_base/$base/?"] = 'index.php?feed=rss2&withcomments=1';
	return $rules;
}
add_filter( 'rewrite_rules_array', 'fix_broken_get_feed_link');


More information about the wp-hackers mailing list