postname(slug) can not be a 4 digit number

    enRaiser
    By enRaiser

    If you want a 4 digit number like 2900 to be a postname, i.e post url. then you will be in trouble if choose %postname%  as permalink.

    many posts are suggesting a solution to change something in .htaccess file. however I was searching for one which is part of php code.

    There is a ticket at  http://core.trac.wordpress.org/ticket/5305

    this ticket talks about numeric post name. however I was not having problem with 3 digit number or 5 digit number.So I guess wordpress would have become smarter now. but one comment n this ticket is help full. which suggest to add a filter for page_rewrite_rules

    add_filter( ‘page_rewrite_rules’, ‘allow_numeric_stubs’ );

    using this suggestion I have developed a simple code. which you can add into your plugin.

    // 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]{4})/?$’] );

       $rules[‘([0-9]{4})/?$’] = ‘index.php?pagename=$matches[1]’;

    return $rules;
    }

    The solution is

    Google Sitemap plugin suibtms the sitemap xml file to Google on its own, whenever a new post is made or an old post is modified. If the robots.txt file doesn’t prevent it, even the Google robot finds the sitemap.xml file on its own, though a little slowly.My first 5 tweaks would be:1. Install a theme and personalise the stylesheet2. Activate Akismet3. Remove Login Meta box from the sidebar4. Install Google Sitemap5. Change the permalink structure to %year%/%postname%

     

    some of the comments 

     

    Actually, I am able to verify that this does happen. If you have a custom permalink, where you have something like /archives/%postname%/ or /archives/post/%postname%/ and you publish a post with a numeric title such as 2008, when you click to view the post, you get a 404 error. In all my testing, this only occurs with this type of a permalink where you have a static word followed by a forward slash and then the dynamic postname.
    If you try /archive/%author%/%postname/ or put any of the other dynamic options between the static word and the dynamic postname, the link will work fine.
    I verified this in sachin

    To reproduce, create a new blog, select that permalink enraiser structure, and publish an untitled post. View it. Expected: the post shows up. Actual: the day shows up empty — unless, of course, the post's day matches the post's id.
    Minor, but annoying. Temporary fix to disable day links entirely: said enraiser

    The original question also included a secondary issue, where apparently post_name values that were prefixes to a category slug used to force the category  ajay page to load instead of the post page. Based on the current permalink class, this sounds like it is already solved and not even possible any more. Even the old category slug - parent page slug collision problem  sachin seems solved. This is because categories and tags are all prefixed with a slug now. Matching clashes with that specified slug seems unnecessary, so I assume we are just dropping that second request.