Yes this is possible using add_rewrite_rule()
, something along the lines of
add_rewrite_rule(
'test-subject/(\d+)/?',
'index.php?post_type=CPT_slug&post_id=$matches[1]'
);
add_rewrite_rule(
'ts/(\d+)/?',
'index.php?post_type=CPT_slug&post_id=$matches[1]'
);
It might be a bit trickier though, since test-subject/test-title
and test-subject/post_id
are quite similar. Adding the post_id
-rule with the 3rd argument as 'top'
might help.
Related Posts:
- Creating a custom public user page
- Custom Post Type get_post_type_archive_link( $post_type ) returns false
- Custom Post Type rewrite
- Custom Permalink to remove category word , keeping posts permalink with date?
- Set a CPT slug as a base name for all the taxonomies
- restricting custom rewrite to just one custom post type
- Permalinks: custom post type -> custom taxonomy -> custom sub taxonomy -> post
- Menu Structure and URL structure, with Pages and Post-Type-Posts
- How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy
- How to set a fall back template for a custom post type in a plugin?
- How to add multiple images to custom post type?
- Slug for custom post type archive
- get_edit_post_link() not working as expected when passed id in plugin
- Change page /2 to /transcript with a Rewrite
- Permalink rewrite with custom post type and custom taxonomy
- How do I Make a custom post type get a custom post template in a plugin
- How would I leverage custom Taxonomies in this scenario?
- WordPress metabox file upload in custom post [duplicate]
- working Custom Post Type and Widget code no longer works when moved from functions.php to plugin
- WordPress custom post action hook
- On clicking on the category name the page is redirecting on 404 pge
- Interesting Custom Post Type Slug with Taxonomy and Custom Field
- WordPress Rewrite rule for nested post types
- Category base to url in custom post type/taxonomy
- How to: add option to add more checkboxes on custom post type
- how to set default value for checkbox in wordpress
- How to Combine Two Custom Post Types into Single Permalink Structure
- Customize permalink when creating a post
- Custom Taxonomy Not Showing in Menu
- Redirecting when changing custom post type slugs?
- need advice on how to do a lists using custom post types – taxonomy vs postmeta
- How to remove slugs from multiple custom post types
- Custom taxonomy in URL showing 404
- WordPress theme custom capabilities not works
- Rewrite slug of custom post type to include post-id
- How to change custom post type permalink structure
- Front custom edit post page for each post
- Categories of Custom Post throws gives 404
- How to build custom route by adding taxonomies to URL ? ex: www.demo.com/communities/palo-alto/
- Orderby CPT custom fields not working
- 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
- Rewrite Question Mark in Post Template to Make it Pretty URL
- WordPress custom post type split into pages
- Including taxonomy term before post type breaks top level pages
- Correct procedure for advanced permalinks
- Custom Post Types hierarchy and rewrite
- How to get list of taxonomy slugs ordered parents>childs?
- Rewrite Endpoints and CPTs – How to use in a plugin
- Plugin fatal error
- Custom post type’s permalink adds the name of the post type before the post name
- Custom taxonomy and post type with same slug
- Suggestion on custom post type/ taxonomy relationship
- I can’t access custom taxonomy page listing
- Combine multiple CPT names to create valid permalinks
- How do you make a list and list item relation if custom post types?
- Add form after woocommerce admin order edit
- How to rewrite custom taxonomy term archive to use THE SAME SLUG/front as CPT
- How to Use Custom Meta Field Instead of CPT Title in Post URL
- How to create custom search result page with custom URL parameters for custom post type?
- Page inside custom post type (url rewrite?)
- Validate Custom Post Type fields
- Is it possible to sort metabox teaxtarea values?
- Custom Post Type View Button in Admin Gives 400 Error
- Modify a plugin function output from another plugin
- Custom Post Type URL Rewrite’s
- Custom rewrite rules for /pastissues/%category%-%postname%.html
- Content in WP Editor displayed below CPT shortcode [duplicate]
- Writing a custom Glossary plugin
- Change Text in Admin Panel
- How to show Custom Post Types under Taxonomy in a new WordPress page template?
- Custom Endpoint For Specific Custom Post Type
- How to apply multiple rewrite_rule to a single custom post type url?
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- How to display the post using a shortcode in WordPress?
- Custom post type specific item design
- Shortcode and get_template_part
- dynamic vue widget inside custom post
- Getting data from dynamically allocated metaboxes within a custom post
- Rewrite url for custom post type with specific url
- WP REST API Custom endpoint don’t work in my plugin
- How to make “single post” permalink maintain it’s sub-page structure
- how to allow subscriber to add/edit/delete custom post type
- Two CPT: one is using part of the custom rewrite slug from the other
- Facing some Issues on Two Parts Custom Post Type Taxonomy Names
- Custom meta box in editor of custom post type not working
- Remove Custom Capability
- Can I override the permalink/slug on creation
- Rewrite Endpoint Url without ? before endpoint
- How Can a CPT in WordPress have a page 2 without an error?
- call_user_func_array() error after moving to another server
- Remove sequential number from permalinks
- Parent cpt/child custom post type URL permalink relationship
- Issue on Adding Taxonomy to Custom Post Type Using Function
- Custom Post Types in plugins?
- How to apply order on custom taxonomy and custom meta key on custom post type
- Hide custom post type and use its slug in new plugin menu
- Don’t display post if post has empty body
- How to rewrite custom slugs that follow my rules
- What is the best way to relate different custom post types?