Title: Remove post type slug
Last modified: December 6, 2022

---

# Remove post type slug

 *  Resolved [x1code](https://wordpress.org/support/users/secretja/)
 * (@secretja)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/remove-post-type-slug/)
 * Hi,
 * After update of plugin and WordPress, on staging, I have a problem with removing
   post type slug. Slug is “landing”.
 * CPT UI settings for custom post type:
 * Rewrite: True
    Custom Rewrite Slug: empty With Front: False.
 * Functions:
 *     ```
       function na_remove_slug( $post_link, $post, $leavename ) {
   
           if ( 'landing' != $post->post_type || 'publish' != $post->post_status ) {
               return $post_link;
           }
   
           $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
   
           return $post_link;
       }
       add_filter( 'post_type_link', 'na_remove_slug', 10, 3 );
   
       function na_parse_request( $query ) {
   
           if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {
               return;
           }
   
           if ( ! empty( $query->query['name'] ) ) {
               $query->set( 'post_type', array( 'post', 'landing', 'page' ) );
           }
       }
       add_action( 'pre_get_posts', 'na_parse_request' );
       ```
   
 * All works on production but on staging I get 404. Can subdomain.domain.com affect
   this? I don’t have any other good ide why this don’t work.
 * Thank you!

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

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [3 years, 6 months ago](https://wordpress.org/support/topic/remove-post-type-slug/#post-16265621)
 * Have you flushed your permalink rules recently? That can be done via visiting
   the permalinks settings page and just clicking save without touching anything.
 * I don’t think the domain matters, or in this case subdomain.
 * We also presently recommend a well-tested permalinks plugin like [https://wordpress.org/plugins/permalink-manager/](https://wordpress.org/plugins/permalink-manager/)
   for this type of customization. Worth checking out and trying, and would remove
   the need for the extra code above.
 *  [hornedcrosis](https://wordpress.org/support/users/hornedcrosis/)
 * (@hornedcrosis)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/remove-post-type-slug/#post-16274568)
 * Hi Michael, I have a similar issue (so I won’t open another post).
 * I created a new content type (called “Copywriting”). I need the URLs of these
   content types to show the Post_ID, like I do for articles and pages.
 * For example, an article is example.com/?p=123
 * CTP UI does something similar, since it creates example.com/?copywriting=slug.
   However, I need to remove the slug part and make it so that the url looks like
   this: example.com/?copywriting=456
 * Is it possible to do directly with your plugin? I searched all around with the
   options, but I can’t find it. I also tried with Permalink Manager, but I can’t
   find a way to show the URL with ? and = symbols.
 * Thank you 🙂
    -  This reply was modified 3 years, 6 months ago by [hornedcrosis](https://wordpress.org/support/users/hornedcrosis/).
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [3 years, 6 months ago](https://wordpress.org/support/topic/remove-post-type-slug/#post-16275427)
 * Hi [@hornedcrosis](https://wordpress.org/support/users/hornedcrosis/), CPTUI 
   itself doesn’t do anything special with rewrites, outside of allow for specifying
   what the slugs for the content types could be. As a very quick example, changing“
   copywriting” to “copyediting” for the permalinks.
 * From what I see with your request the permalink would essentially read as “post_type
   =post_id” which would be a bit interesting to attempt to implement. the “p=post_id”
   already gets mapped internally when WordPress parses out the request. So you’d
   need to somehow set rewrites and mapping to somehow have “copywriting” get parsed
   out as “this will be the post ID to fetch”. I don’t have answers for how to achieve
   that admittedly.

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

The topic ‘Remove post type slug’ is closed to new replies.

 * ![](https://ps.w.org/custom-post-type-ui/assets/icon-256x256.png?rev=2744389)
 * [Custom Post Type UI](https://wordpress.org/plugins/custom-post-type-ui/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-post-type-ui/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-post-type-ui/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-post-type-ui/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-post-type-ui/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-post-type-ui/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [3 years, 6 months ago](https://wordpress.org/support/topic/remove-post-type-slug/#post-16275427)
 * Status: resolved