Support » Plugin: Custom Post Type UI » base slug removal 2020

  • Resolved uhorcik

    (@uhorcik)


    Hi! I know this question has been asked a million times before but i couldnt find any working solution and the topics i found are more than 2 years old so i need to try to ask again.

    Is there a way to remove the base slug from CPT permalink?

    Im trying to achieve this: mypage.com/%custom_taxonomy%/%postname%/ (using “Custom Post Type Permalinks” plugin to add the taxonomy) but im getting 404 every time i get the url to look like that. I tried to re-save permalinks settings but it didnt help.

    Is there a working solution or this is still not possible in any easy way?

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

    (@tw2113)

    The BenchPresser

    Probably that last part, with not possible in any easy way.

    Unless the permalink rewrite rules are created and configured properly, I suspect that permalink structure would consider the taxonomy portion to be the post type, and thus not find any post to display.

    Each part of the url is actually pretty important except in cases around the “post” post type which gets special treatment. Each portion is what tells WordPress what to query for. In this case, “a post named POSTNAMEHERE from POSTTYPEHERE”. I believe without specifying the post type,it defaults to just “post” which isn’t the case. So at least with removing base post type slugs from the permalinks, it’s typical to tell WP to search through both “post” and whatever post type is actually intended.

    However, that taxonomy slug part I suspect would through a bigger wrench into things for this case.

    Thread Starter uhorcik

    (@uhorcik)

    @tw2113 Thank you for such a quick answer! I was afraid you would say that. Unfortunately using the default post template is not possible in my case and the taxonomy slug has to stay in the url. Isnt it possible to force the custom post type to skip looking for single-{…}.php files and instead grab a custom template file?

    I tried this but no effect:

    
    <?php
    /*
    Template Name: My Template Name
    Template Post Type: my_custom_post_type
    */
    ?>
    
    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    using that technique above wouldn’t automatically apply the template for each post, you’d have to select the template each time you create a new post in it.

    Thread Starter uhorcik

    (@uhorcik)

    Yes but unfortunately even after selecting the template i still get 404

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Sounds like, then, that some aspect of the query being made isn’t finding results. Did you undo any of the related permalink changes and flush the permalink rules by visiting the appropriate settings page?

    Thread Starter uhorcik

    (@uhorcik)

    Yes i did that a multiple times :/

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Hard to say at this point what’s going on, especially from my end where I don’t have any access at all.

    I know that I use https://wordpress.org/plugins/query-monitor/ for almost all my custom dev work and some of its panels could offer an idea of what’s going on and what requests are being made here, to further deduce why things are not working.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘base slug removal 2020’ is closed to new replies.