[wp-hackers] Make WP_Rewrite eaiser to use

Peter Westwood peter.westwood at ftwr.co.uk
Mon Feb 6 09:52:39 GMT 2006


On Mon, February 6, 2006 9:31 am, Sam Angove wrote:
> 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');

Don't forget that you need to do this for _every_ post/page permalink
rewrite rule as well it's not just the root feed that is broken.

This is why WP_Rewrite needs fixing to support this rather than trying to
hack arround it.

westi
-- 
Peter Westwood
Blog: http://blog.ftwr.co.uk



More information about the wp-hackers mailing list