Working with post slugs that have only numbers

Support MB Custom Post Type Working with post slugs that have only numbers

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #48162
    ZakirZakir
    Participant

    I think with some struggle I've learned that WordPress no longer allows post slugs to be a numeric value exclusively.

    That means I cannot do website.com/programs/summer-camp/2025

    because wordpress automatically adds a hyphen to the post slug that is only a number. So it becomes

    website.com/programs/summer-camp/2025-2

    This is frustrating.

    I want to create a hierarchical CPT called "Programs" with slug "programs". Then I want the parent posts to serve as evergreen content pages for SEO purposes. So for example I would create the following parent posts

    website.com/programs/summer-camp
    website.com/programs/history-month
    website.com/programs/ramadan

    And then every year there is an annual recurrence of these programs. So I was thinking of doing child posts for each

    website.com/programs/summer-camp/2025
    website.com/programs/summer-camp/2026
    website.com/programs/summer-camp/2027

    website.com/programs/history-month/2025
    website.com/programs/history-month/2026
    website.com/programs/history-month/2027

    website.com/programs/ramadan/2025
    website.com/programs/ramadan/2026
    website.com/programs/ramadan/2027

    But unfortunately, WordPress won't accept those child posts as "2025", instead it forces "2025-2".

    How can I approach this so that I can achieve the desired URL structure? Are there better approaches?

    ChatGPT suggested to create a 2nd CPT called "Program Sessions" with slug "program-sessions" and then try to use rewrite rules to rebuilt the struture.

    #48167
    PeterPeter
    Moderator

    Hello,

    As you can see that, it is a WordPress issue, not an issue of Meta Box itself. You can follow this topic https://wordpress.stackexchange.com/questions/481/can-i-use-a-number-for-a-post-page-slug
    there are some workarounds to fix the issue: use a third-party plugin, or use another permalink setting: Day and name or Numeric.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.