[wp-hackers] RE: Allowing numeric-only titles for posts

Dan Fellars danf at eliresearch.com
Mon Mar 2 22:59:10 GMT 2009


> Addition, there's a plugin that remedies this, at a cost:
> http://wordpress.org/extend/plugins/allow-numeric-stubs/

Thanks Otto - after looking at viper007bond's plugin it only works for
adding numeric stubs to pages, not posts ( he just adds filter for
'page_rewrite_rules').

Im not too familiar with the rewrite rules, so would be afraid of
breaking anything, but if I used his same function, but modified for
posts:
Add_filter('post_rewrite_rules', 'allow_numeric_stubs_post' );

Then changed his allow_numeric_stub to:
function allow_numeric_stubs_post( $rules ) {
	unset( $rules['(.+?)(/[0-9]+)?/?$'] );

	$rules['(.+?)?/?$'] = 'index.php?p=$matches[1]';  //just replace
'pagename' with 'p'

	return $rules;
}


Do you think that would work for posts?  I will try it out and see what
happens.....







More information about the wp-hackers mailing list