Here’s a way how to change the slug:
add_action('wp_insert_post', 'change_slug');
function change_slug( $post_id ) {
// Making sure this runs only when a 'eduation' post type is created
$slug = 'eduation';
if ( $slug != $_POST['post_type'] ) {
return;
}
wp_update_post( array(
'ID' => $post_id,
'post_name' => $post_id // slug
));
}
Related Posts:
- Remove slug from custom post type post URLs
- Redeclare/Change Slug of a Plugin’s Custom Post Type
- Custom Post Type Slug / Page Slug Conflict – Prevent use of reserved slug on page save?
- How to get custom post type label and singular label from its slug?
- Custom Post type & Taxonomy URL structure
- Slug Formatting : Acceptable Characters?
- Combining Multiple Taxonomies in one URL
- Change slug of registered custom post type in child theme
- Post slug changed using code doesn’t reflect on editor when post is published
- How to achieve this permalink -> category-name/custom-post-type-name/post-name
- Prepend meta_value to permalink of post
- Custom Post Type – Same Post Name, Different Post Type
- Priority for Categories, Tags, Taxonomies, Posts, Pages and Custom Posts with same url
- Reslug a Custom Post Type
- Force unique page slugs across all post types
- Custom Slug for a custom post type and default post
- Remove taxonomy slug when not assigning taxonomy with custom post types
- Interesting Custom Post Type Slug with Taxonomy and Custom Field
- Get slug to point to different content of the same post
- Remove Taxonomy Slug when No Taxonomy is Assigned to Custom Post Type?
- Using custom post type parent as slug
- Custom post type with slug for plural (archive) and for single
- Fetch ID’s associated with a custom post type when translated with WPML?
- How do I fix permalinks for custom post types that has the same slug as a page?
- How to remove slugs from multiple custom post types
- Custom post types archive redirect
- Why does wordpress keep adding postname to my CPT’s permalink in the end?
- Remove post type slug of all post types from permalinks
- Am I using the flush_rewrite_rules function in the right place?
- Rewrite slug for CPT
- Is there a way to have custom post type and page with the same slug?
- Using Same Slug With Multiple Post Types
- Rewrite post type slug only for child theme
- Adding Post id to the end of slug in a Custom Post Type
- Remove the parent slug in a CPT URL
- Permalink for a custom post type isn’t working and I don’t know why
- Index page with the same id as the slug
- How can I make the slug of the taxonomy also the slug of the custom post
- Assign same parrent Page to pages AND custom post types
- Query Post Object in WP Admin
- Custom Post Type with Same Page URL
- Post ID randomly printing on page
- Multiple (two) category postings on the same page.
- Removed custom post type slug but not working for child pages
- Including taxonomy term before post type breaks top level pages
- Can slugs from posts and custom post types conflict?
- Auto Slug Generation for Custom Post type
- How do you create %post_type%/%postname%/ permalink structure?
- Slug Confusion Between Post and Custom Post types?
- How to find a specific post_type using its “rewrite slug”?
- Different slug taxonomy for two different CPT
- Change Slug of a Custom Post Type
- How can Custom Post Type and a page have the same slug?
- How to get postname in custom page?
- Changing slug of all posts
- WordPress different templates for same type custom post (but different slug)
- Custom Post Type Advanced Slug
- Apply template by path/slug related to custom post type?
- Changing CPT slug and taxonomy already registered in parent theme
- Custom Post Type to replace Woocommerce products – page not found error
- Custom Post Type for Shortcode Use – Prevent it display as a post (with slug)
- Custom Post Types and Removing Slugs – should we do it?
- Need to return a string as permalink insted of str_replace
- Give a unique ID while saving
- Under What Conditions Can I name my CPT the same as my CPT Page?
- Custom post type and multi taxonomies + customize url
- Custom rewrite rule based on other custom post type title
- Use custom post type taxonomy between cpt slug and name
- How is possible to know ID of taxonomy-{taxonomy}.php page for ACF fields
- Show code dependant on CPT & category
- Remove custom taxonamy slug with pagination
- How to only get the content of post page while looping?
- WordPress doesn’t respect Page slug in custom post type url pagination. Keeps getting removed
- Add %post_id% to slug of custom post type and prevent the “unique slug” thing that WP does?
- Output all terms slugs for a loop filter
- get_post_meta not working with variable as a post_id for dynamically get the postid
- add .html to custom post type with WPML
- Custom Post Type duplicating slug for new posts
- Display result as “prefix+ID” and show in the search result as bookcode
- WordPress page not showing up – replaced with last 10 posts?
- Custom permalink rewrite rules – how do I fix this?
- Display a Custom Post Type within another with hierarchically slug
- Generate slug and meta data if meta field is empty
- Can’t make permalink of CPT work
- Custom Post Type Rewrite Rule
- How can I retrieve the slug for a custom post type via name?
- WP Query Post Type with same Taxonomy name
- WP Query WordPress Post Type with the same Taxonomy name
- Ideal top-level slug methods
- Is this the correct way to add post-slug input field?
- Create page using same slug as custom post type
- Filter page ID outside the loop and order
- Custom Post Type with multiple Custom Taxonomies / Hide Taxonomy Slug from URL
- Same slug for Custom Taxonomy archive and CPT archive – Rewrite rule not working
- Removing custom post type name from permalink
- Custom Post Type slug has the same Redirection entry
- How to change rewrite slug for custom post type without conflicting w/ child pages of page with same slug
- Custom post type URl Cutomization
- Right Permalink for Custom Post Type with number slug
- Custom post type slug localization