• Resolved ladydev

    (@ladydev)


    I have an existing custom post type on a site and have a request to remove the slug, so for example ‘somesite.org/ebook/ebooktitle’ to ‘somesite.org/ebooktitle’. I’ve set the ‘With Front’ option in CPT UI to False and then resaved the Permalinks however it doesn’t work.

    I found solutions and some hacky things online but nothing worked. Then I came across your solution here https://michaelbox.net/2020/06/slugless-post-type-permalinks/ (I tried to comment on your post btw but the WordPress Zero Spam plugin on your site thinks I’m spam *shrug*). Anyway, the code does remove the slug but the pages return 404s, flushing the permalinks didn’t help. I did notice through my testing that the Permalinks on the site are set to a Custom Structure %category%%postname% I wondered if changing it from Custom Structure to Post name would work and it did. I’m just trying to sort out why your solution doesn’t work with the Custom Structure. Do you have any ideas on how I might fix that? It would be greatly appreciated because it’s driving me crazy. ??

    Cheers

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

    (@tw2113)

    The BenchPresser

    Hello, so you’re the hit to my analytics today ??

    Sorry about the spam part, not sure why it’d think that and I will have to investigate.

    Regarding the custom structure part, I don’t have an immediate answer why it needs to be the %postname% only version, but that’s what I had always seen when previously googling this topic. If I find out why, I will definitely add to the post to include explanation. That said, I don’t have an alternative version available to have it also work with %category%%postname%

    Out of curiosity, what solutions is that version of the permalink rewrites solving?

    Thread Starter ladydev

    (@ladydev)

    ?? Yep, that was me.

    So this particular site has been around for a while and that’s how the permalink structure was set up when I started maintaining this site and others for the org. The SEO team had requested it, I believe, so changing it at this point might cause further issues and a larger discussion since I can’t just go ahead without SEO approval which I may not get.

    I’ll run it past the SEO manager and see whether it’s still a thing, we had a person managing SEO prior to this individual that made that choice.

    I just want to resolve it and move on with my life. ??

    Hi @ladydev,

    I had the same problem and used this code: https://kellenmace.com/remove-custom-post-type-slug-from-permalinks/

    Important: do not use a slash for the front. Otherwise, you might break other parts of the site (in my case the WooCommerce endpoints became 404s) and might spent days with turning plugins on and off again, until you came across the cause. So @tw2113, maybe you can address this in a future apdate with at least a warning.

    Best regards!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    @89garvhf23 Coincidentally Kellen’s post is where I adapted mine, and he’s a friend and former coworker at WebDevStudios.

    Regarding your comment about the slash for the front, are you referring to something in the code from Kellen’s and my posts? Or is this in regards to perhaps the rewrite_slug setting in CPTUI and general post type registration? Leave it default so that falls back to post slug, or set it to something, whatever is chosen?

    Trying to make sure I potentially update the post accurately.

    Hi @tw2113,

    Thanks for your reply. Funny. I did not check your code. Just realized it did not work.

    I am referring to CPTUI where I put a slash as a front in the CPT settings and probably (not sure anymore) adapted Kellen’s code to work with that. Maybe it even worked without modification.

    But that led WordPress to go 404, either on the WooCommerce endpoints or the CPT I created with CPTUI, depending on the right procedure of activating/deactivating CPTUI and saving permalinks (which was the time sonsuming part to find this co-relation).

    I guess, it would also be a general problem. But I did not check for that.

    Thanks for the great work on this plugin!

    • This reply was modified 2 years, 11 months ago by 89garvhf23.
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    @89garvhf23 @ladydev either of you come to a working solution for your issues here?

    Hi @tw2113,

    Thanks. I solved the issue. Using the code from above and leaving out the slash as a front in the CPTUI settings works for me. Thanks for asking.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Setting ‘With Front’ to False Does Not Work’ is closed to new replies.