WordPress.org

Ready to get started?Download WordPress

Forums

Can't have a post_name with just numbers? (9 posts)

  1. t3ch33
    Member
    Posted 4 years ago #

    I'm trying to create pages that have post_name set to just a number, like "123456". When you visit those pages - site.com/123456, for example - the page cannot be found. If you change the post_name to include a letter - site.com/a123456, for example - the page appears. Any idea how I can get around this? My permalinks for the posts use the post ID, if that makes a difference.

    Thanks

  2. henkholland
    Member
    Posted 4 years ago #

    Under Permalinks/Custom structure this works for me: /%post_id% and this also /%post_id%/

    You did do the .htaccess thing offcourse because a123456 works?

  3. t3ch33
    Member
    Posted 4 years ago #

    I have an htaccess file that I've been using, and post_id is set as the permalink. I don't know why for the pages, it only works if post_name does not only contain numbers.

  4. henkholland
    Member
    Posted 4 years ago #

    Just gave it a try out in wp 2.9.1. and I can confirm the behaviour. A new page with a name and page-slug consisting of only numbers gives a not found. So page name and slug 123 did not work where as a123 does work.
    Must be a WP internal thing+ maybe worth a bug report.

  5. Mark / t31os
    Moderator
    Posted 4 years ago #

    Problem doesn't exist in 3.0, so you're proberly wasting your time with the bug report as it's clearly been fixed for 3.0..

    I created 2 new pages to test, one called 123456, and another called 7890, both worked fine, the permalinks were as follows...

    localhost/123456/
    and
    localhost/7890/

    However i do have a slight difference in my permalink settings, i use..

    /%postname%/
  6. henkholland
    Member
    Posted 4 years ago #

    Yep, when I change to /%postname%/ it works but I prefer my permalinks to start with a numerical item to keep up the speed.

    /%post_id%/ does NOT work and /%post_id%/%postname% does also not work

    Qoute: "For performance reasons, it is not a good idea to start your permalink structure with the category, tag, author, or postname fields. The reason is that these are text fields, and using them at the beginning of your permalink structure it takes more time for WordPress to distinguish your Post URLs from Page URLs (which always use the text "page slug" as the URL), and to compensate, WordPress stores a lot of extra information in its database (so much that sites with lots of Pages have experienced difficulties). So, it is best to start your permalink structure with a numeric field, such as the year or post ID."

    from here: http://codex.wordpress.org/Using_Permalinks

  7. Mark / t31os
    Moderator
    Posted 4 years ago #

    Ok a little off-topic but..

    Any site with a large number of pages is going to suffer performance issues vs one with few pages anyway, pages each have an array of several rules, post's use a more "one for all" approach in a manner of speaking.. so require less rules to manage them all... ( i use very few pages )..

    Print out the rewrite rules array and look at what's there, you'll find a much larger assortment of rules for pages..

    I'm sure not about the numeric problem in any case...

    Does the post/page save with the numeric value and load the correct url? (even if an error message is shown)..

  8. henkholland
    Member
    Posted 4 years ago #

    It saves and in the dashboard it shows the postnumber (4856) for my test page.
    In the dashboard it shows as page_id=4856

    So when I set the permalinks to default, I can call the page through:
    http://www.mysite.com/?page_id=4856 and offcourse not through ../123

    Now when I set the permalinks to /%post_id%/ ../123 is a no go and http://www.mysite.com/?page_id=4856 gives an error BUT the address bar switches to ../123 (funny)

    And when I set the permalinks to /%page_id%/ everything works fine and I can call the page through www.mysite.com/123 and also through www.mysite.com/?page_id=4856 and then the browsers address bar switches to ../123

    Note 1: /%page_id%/ is not in the list here: http://codex.wordpress.org/Using_Permalinks

    Note 2: I did not test for internal broken links but it seems to work.

  9. Mark / t31os
    Moderator
    Posted 4 years ago #

    I'd have thought using post_id would fail for pages, and vice versa for posts (page_id).. i'd say that's behaviour i'd expect, but then i'm not immediately familiar with the inner workings of the rewrite class to comment defintively on the matter..

    An alternative might be to use a more common permalink setting, and then write your own custom rule(s) for particular/special pages that need to be handled a certain way..

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.