Custom Fields
Re-Envisioned
Support MB Custom Post Type Suggestion: Limit Custom Post Type slug to 20 characters

This topic contains 2 replies, has 2 voices, and was last updated by  Anh Tran 8 months, 2 weeks ago.

  • Creator
    Topic
  • #13415
    Resolved
    Purdue Alumni Association
    Participant

    Recently I encountered an issue trying to create a new Custom Post Type. I created it and published, but it did not show up in the menu as expected. I found the issue was the automatically created slug was longer than 20 characters:

    $post_type
    (string) (required) Post type. (max. 20 characters, cannot contain capital letters, underscores or spaces)
    Default: None

    https://codex.wordpress.org/Function_Reference/register_post_type

    I’d recommend limiting the automatic slug creation to 20 characters. Some UI element to count the characters with a warning why it is limited may help future users.

    My use case:
    CPT name of ‘Business Directory Listing’ converts to ‘business-directory-listing’ (26 characters) Changing it to ‘biz-dir-listing’ fixed the issue. Maybe there’s a good reason why it is limited to 20 characters, but it seems awfully small to me.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #13417

    Anh Tran
    Keymaster

    Hi Purdue,

    This is a good suggestion. At the moment, there’s no restriction yet. I’ll add that to the next version.

    #13580

    Anh Tran
    Keymaster

    It’s done in the latest version of the plugin. Please update!

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.