• Resolved mburdick

    (@mburdick)


    I’ve seen this topic a few times but still no answer that works.

    I’m trying to import custom post types set up by a former employee that used the slug “help-doc”. When I try and type, copy/paste or anything, the field changes to an underscore.

    Is there a way to get around this? If not, then I fear my only action is to create a child theme based on her old CPTs and then I wouldn’t even need a plugin.

    Thanks again!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Cross posting for visibility.

    https://www.ads-software.com/support/topic/how-to-add-dash-to-custom-post-type-slug/#post-11259607

    The hyphen would be the last thing you want to paste before clicking away from the input and making it lose focus.

    For instance if you wanted “my-post-type”, you would need to type out “myposttype” and then paste in the two hyphens in the appropriate spots with mouse/trackpad only.

    Thread Starter mburdick

    (@mburdick)

    OK got it. Thanks!

    jackhowell

    (@jackhowell)

    I’ve attempted this, following the paste method correctly, but no matter how I try to sneak up on the input field it always changes to underscores.

    My problem is: I’m importing custom post type data from another site, where they are hard-coded with hyphens. So even using the slug re-write, the CPT still has an underscore, so the import fails to find the categories.

    I completely appreciate the technical reasons why this is in place. Please add an advanced setting to disable the keyboard hyphen to underscore function.

    In the meantime, is there any other way around this?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    @jackhowell are you going completely mouse/trackpad based? Cause it’s all keyboard driven.

    Alternately, it’d be really easy do remove the enqueuing of our js long enough to get your work done.

    You can find the line at line 37 of plugins/custom-post-type-ui/inc/post-types.php

    I’ll file an enhancement issue to consider and look into options to help with the topic, especially around when importing.

    jackhowell

    (@jackhowell)

    Thanks, @tw2113, yes, this is entirely trackpad driven on OSX.

    It usually wouldn’t be a problem but, in this case, I have 250+ posts all using a series of categories and tags with hyphens in them to import.

    I used Chrome to paused the DOM, pasted the text, resumed JS and saved. Temp fix, worked OK. Bit messy.

    I expect using a different method of importing the posts I could rename them to use underscores, or even edit the XML to replace all the names with the more suitable underscore version. However, if the client wants to re-import again (and again) due to changes, that would be a repetitive task.

    Thanks for looking into it!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    In terms of importing, what aspect are you importing? The post data? Asking because we don’t have any import functionality built in for CPTUI itself and getting settings set.

    Once things are saved right in CPTUI, you shouldn’t need to re-touch those settings again, even if you re-import the POSTS for the post type. On top of that, you could amend the slugs to be what you intend them to, before running any imports, and they could match what is saved in the however many slugs/post types you have registered with our plugin.

    Even then, using the import/export of CPTUI SETTINGS, from one install to another, would take what gets imported and save that. We don’t convert/switch during the import process. Only once you start typing in one of the two fields.

    jackhowell

    (@jackhowell)

    Post data, yes.

    I might have confused the matter: this is strictly to do with importing data using WP Import/Export for posts, not CPTUI settings.

    I meant if I had not been able to set the hyphen, I could have modified the data XML before import to use the “new” underscore format. So that when importing into the new site, WordPress recognised post_type_name (as it would be renamed in the data).

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    At technical levels, it would have imported just fine still, but until the slugs matched up again, they wouldn’t be recognized. You can have the post_type slug in the wp_posts table be anything, but until that value is recognized as a post type, I don’t think you’d be able to query a bunch, at least without doing direct SQL.

    Just some thoughts.

    Hopefully you’ve gotten a solution in some way since earlier.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Another hyphen underscore question’ is closed to new replies.