Support » Plugin: Custom Post Type UI » Can't Delete a Custom Post type with spaces

  • Resolved Squidpeg9

    (@squidpeg9)


    I accidentally made a custom post type with the slug “glenn files.” Notice the space. This obviously doesn’t work in the URL. With every other post type, I can make and delete, but this ONE will not let me delete. Instead, it gives me the error “Please provide a post type to delete.” Even though I AM selecting a post type to delete.

    I am pretty sure that the issue is because I accidentally made it with the space. Unfortunately, I don’t know enough about WP files to know where to go to manually remove it. Please help!

    https://wordpress.org/plugins/custom-post-type-ui/

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    The issue ends up being that the keys in the arrays aren’t matching, due to the space.

    I recommend using the import/export functionality here. Grab the export code, copy it back into the import textarea on the left, fix the space in the slug with an underscore, and click import.

    This will overwrite the previous settings with your new ones, which are going to be the exact same except for that space is now an underscore, and everything is all hunky dory 🙂

    Let me know how this goes for you.

    PERFECT! Thank you so much. I was running around in circles on this. 🙂

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome

    Thx too 🙂

    @michael Beckwith great fix! I was running in circles with that too. Fixed!

    Me too! Thanks Michael.

    Great fix!

    Thanks!! 🙂

    Perecto!

    Hi sorry if this is a bit off-topic, I’m using cpt-ui and don’t want to mix dash and underscore in the url, so I was wondering if – or how – I can use a dash in the template name, I’d like the name to be:
    single-medicinal-plant.php.
    So the Post Type Slug would be medicinal-plant
    Is this ok or how do I make a url with only dashs?

    Thanks for your help
    David

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Unless your setup somehow has it set up to explicitly use the template name as part of the URL, then that shouldn’t be an issue with underscores. The URL would still use just the post slug/url for the post.

    As far as I can see on the current version of the codex, it doesn’t say not to use dashes, but there is still valid reason to keep them as underscores, like the following:

    “Also, if the post type contains dashes you will not be able to add columns to the custom post type’s admin page (using the ‘manage_<Custom Post Type Name>_posts_columns’ action). ”

    Hi, thanks for your reply, seems confusing that you have to mix dashes and underscores in a template name, suppose a better solution is to make the slug a single word like medicinalplant.
    Spent a lot of time trying to clarify this, thanks for making it clear.

    David

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Well, it’s just a file name on the server at the end of the day. WP does some parsing based on the post type slug to check if a single-whatever.php file exists.

    However, not using any is a solution as well. Whatever works best for you really.

    I ended up here after reading about the issue with spaced over on github and just thought I would throw in a comment about dashes vs underscores.

    Adding columns when a post type name contains dashes vs underscores works fine, or at leas I’ve not had any problems with it working. I’ve created several like “case-study”, “office-location” and “{COMPANYNAME-products}” without any issues adding custom columns to the admin page. There are also other popular plugins that also use dashes in post type slugs without any reported problems, for example ACF uses “acf-field-group”.

    I think that this statement in the codex is incorrect.

    ~JH

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Long story short in my head is use either a dash or underscore, but never a space.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Can't Delete a Custom Post type with spaces’ is closed to new replies.