Well, there is another way. And better, I guess.
You should look at register_post_type
parameters. You should probably set them like this:
'public' => false, // it's not public, it shouldn't have it's own permalink, and so on
'publicly_queryable' => true, // you should be able to query it
'show_ui' => true, // you should be able to edit it in wp-admin
'exclude_from_search' => true, // you should exclude it from search results
'show_in_nav_menus' => false, // you shouldn't be able to add it to menus
'has_archive' => false, // it shouldn't have archive page
'rewrite' => false, // it shouldn't have rewrite rules
If post type is not public, then you won’t see this part of editor.
Related Posts:
- How to change “Draft” string for status of custom post type to “Unavailable”?
- How to correctly get post type in a the_title filter
- post_type_link filter causes 404 on the CPT page it’s used on
- Make the ‘all’ filter default instead of ‘mine’ in a custom post type
- What is better: Custom Fields vs Custom Taxonomies with Terms for perfomance, scalability and better user experience
- Remove “Get Shortlink” button in admin of custom post type
- How to get Custom Post ID by adding filter to child theme’s function
- Custom Taxonomy breaking pages permalinks
- Add html to cpt main page / admin edit.php
- register_taxonomy and register_post_type does not work [closed]
- Displaying custom taxonomy in the admin list of a custom post type
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- Filter Posts from the Main Query
- Create new custom post and post category of same name
- how to retain the ability to modify the post slug after applying a post_type_link filter?
- Custom Permalink For Custom Post Type – Working Fine But Broken For Pagination
- Post Click Redirect to Custom URL instead of Single Post Page
- Keep br tags from stripping
- Filter wp_dropdown_categories Per Post Type
- What is the proper way implement a global $wp_rewrite?
- When Attempting to Filter Plugin Generated Content Using Filter post_type_link, Permalinks Are Not Modified
- add category name to permalinks on product page /category-name/product-name
- Filtering WP_Query
- Use menus with anchors
- Custom Post Type permalink shows wrong page: homepage/index.php
- Get term name and term parent into custom post type permalink
- WordPress add_permastruct unwanted matches
- Rewrite rules for custom posts types
- Permalink structure by Post Meta value
- Does WordPress consider a post name unique if that same post name is in multiple Post Types?
- Why doesn’t a custom post type permalink ever hit index.php
- How can I run this code once so that my generated post title doesn’t keep changing on publish/update?
- filter custom post type by meta key in dashboard
- How to hook custom taxonomies to custom post types and make the permalinks work?
- custom post type parsed as attachment
- Can taxonomies of custom post types be used with category actions?
- Categories of custom taxonomy don’t show any posts
- 404 Issue w/ Custom Post Type – using Meta for Permalink rewrite
- WordPress Custom Post Type Repeated 404 Errors
- Child post with numeric only slug keeps redirecting to parent
- How to change custom post type permalink structure
- How to add a post slug to a url?
- Custom post type url with category
- Help with Elementor Pagination CPT archive 404 problem
- Adding custom post category slug in permalink causes 404 error for pages and posts
- How can I use get_post_meta with add_rewrite_rule to build custom permalinks?
- Allow post/page hierarchy across different post types?
- WordPress sort search results by custom order
- How to filter wp_list_categories output with some custom post type meta query?
- Permalink for a custom post type isn’t working and I don’t know why
- Can’t get custom rewrite tag, query var, permastruct (permalink structure), and rewrite rule to work properly together
- How to Filter custom post type by taxonomy?
- Add custom post type settings to wordress default posts
- How Can I Change the Custom Post Type Slug to the Taxonomy Slug in the URL?
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- WordPress Custom Post Type Permalinks dynamic term slugs
- How to have the same url structure for both a CPT and a Taxonomy?
- How to create custom url structure based on custom post type rewrite slug, taxonomy and category slug?
- create a subcatagory for a custom post type and out put url as posttype/subcategory/item
- How can achieve this permalink perfectly? domain.com/%category%/%post-name%
- custom-taxonomy/post_name instead of the default post_type/post_name
- Filter term taxonomy metabox in custom post type
- Show custom post archive when custom post not specified
- Show custom post type relationships by taxonomy
- creat filter with wp_query
- How do I add a custom screen for a custom post type to be called from custom post row action?
- Custom post type suppress transition from future to publish
- Assign same parrent Page to pages AND custom post types
- Can’t remove front from permalinks for custom taxonomy category page
- WordPress custom post type permalink rewrite shows page not found
- How to set a CPT to have a page as a parent, then rewrite urls accordingly?
- Completely remove custom post type permalinks (“One Page” website)
- Using taxonomy term in CPT permalink – Pages 404’s
- Removing custom post type slug from URL
- How can I made custom taxonomies relationship?
- How to add rewrite rule to custom post type with parent in url with cpt ui?
- Custom post type as home page with custom url
- Customize Custom Post Type URL
- WooCommerce sort products by the actual product width(not the shipping width)
- How to change the post type a theme shows by default?
- Create a custom php page and load it at a specific slug
- URL rewrite add author as base
- Remove CPT name from permalink but add %category% instead
- filter custom post in rest api with custom function
- Permalinks /country/city/cpt/postname/
- Custom Permalink to remove category word , keeping posts permalink with date?
- Rewrite Rule for showing Parent/Child Relationship between Two Hierarchical Custom Post Types
- Seamless permalinks between Custom Taxonomy and Custom Posts
- Custom post type and custom taxonomy with the same slug using the file page taxonomy only as directory
- Need help with permalink rewrites for Custom Post Types with hierarchical relationships
- Custom Post Type Permalink empty
- Filter hierarchical custom post type admin page by parent, and include children & grandchildren
- Custom Permalinks with CPT and Hierarchical Taxonomies
- Sort and filter custom post type posts by custom taxonomy
- Versioned Custom Post Type (Not the same as revisions)
- Change custom post type permalink to show name of post from another custom post type?
- Custom Post Type Permalink
- Permalinks for custom post type
- How to have this permalink structure: post_type/postname/custom_inner_page
- Additional section in custom post type permalink