[wp-trac] Re: [WordPress Trac] #5305: permalinks broken when article name is numeric

WordPress Trac wp-trac at lists.automattic.com
Wed Jul 23 08:48:40 GMT 2008


#5305: permalinks broken when article name is numeric
--------------------------------+-------------------------------------------
 Reporter:  thomask             |        Owner:  anonymous
     Type:  defect              |       Status:  new      
 Priority:  normal              |    Milestone:  2.9      
Component:  General             |      Version:  2.3.1    
 Severity:  major               |   Resolution:           
 Keywords:  permalinks, number  |  
--------------------------------+-------------------------------------------
Comment (by Viper007Bond):

 For anyone looking to do this meanwhile and is willing to give up the
 paging ability, here's a plugin I wrote:

 {{{
 <?php
 /*
 Plugin Name:  Allow Numeric Stubs
 Description:  Allows children Pages to have a stub that is only a number.
 Sacrifices the <code>&lt;!--nextpage--&gt;</code> ability in Pages.
 Version:      2008.07.23
 Author:       Viper007Bond
 Author URI:   http://www.viper007bond.com/
 */


 // Register plugin hooks
 register_activation_hook( __FILE__, 'allow_numeric_stubs_activate' );
 add_filter( 'page_rewrite_rules', 'allow_numeric_stubs' );


 // Force a flush of the rewrite rules when this plugin is activated
 function allow_numeric_stubs_activate() {
         global $wp_rewrite;
         $wp_rewrite->flush_rules();
 }


 // Remove the offending rule and replace it with something else
 function allow_numeric_stubs( $rules ) {
         unset( $rules['(.+?)(/[0-9]+)?/?$'] );

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

         return $rules;
 }

 ?>
 }}}

-- 
Ticket URL: <http://trac.wordpress.org/ticket/5305#comment:13>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list