You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.
Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"
An try thisHow to change the default custom post type slug of the WordPress theme?
Yes, I've tried but the post goes blank? Can you help me, I will send the theme via PM.An try this
How To Change Custom Post Type Slug In WordPress | Scratch Code
Sometimes, WordPress users want to change custom post type slug instead of the default one. In such a case, we will show you the right and good way to dowww.scratchcode.io
I'll try as I canYes, I've tried but the post goes blank? Can you help me, I will send the theme via PM.
I just want to change domain.com/tour/hongkong to domain.com/rute/hongkong.
Thank you in advance. I will send the theme via PM.I'll try as I can
I have tried using Visual Studio Code, changing "tour" to "rute" using the find and replace menu and the slug was successfully replaced, but the single post type rute is blank.After changing the CPT slug with one of the methods described in the link above, you should resave your permalinks. Under Settings > Permalinks.
How to change the default custom post type slug of the WordPress theme?
// PHP 8.x syntax: function changePostTypesSlug( array $args, string $postType ): array {
function changePostTypesSlug( $args, $postType ) {
switch($post_type) {
case 'YOUR_CUSTOM_POST_TYPE':
// Changing the slug
$args['rewrite']['slug'] = 'YOUR_NEW_SLUG';
break;
}
return $args;
}
add_filter( 'register_post_type_args', 'changePostTypesSlug', 10, 2 );
// PHP 8.x syntax: function changeTaxonomiesSlug( array $args, string $taxonomy ): array {
function changeTaxonomiesSlug( $args, $taxonomy ) {
switch($taxonomy) {
case 'YOUR_CURRENT_TAXONOMY':
// Here you can also change the labels easily
$args['labels'] = [
'name' => 'Categories',
'singular_name' => 'Category',
'search_items' => 'Search Category',
'all_items' => 'All Categories',
'parent_item' => 'Category parent',
'parent_item_colon' => 'Category parent:',
'edit_item' => 'Edit Category',
'update_item' => 'Update Category',
'add_new_item' => 'New Category',
'new_item_name' => 'New Category',
'menu_name' => 'Categories'
];
// Changing the slug
$args['rewrite']['slug'] = 'YOUR_NEW_SLUG';
break;
}
return $args;
}
add_filter( 'register_taxonomy_args', 'changeTaxonomiesSlug', 10, 2 );
Yes, I've tried but the post goes blank? Can you help me, I will send the theme via PM.
I just want to change domain.com/tour/hongkong to domain.com/rute/hongkong.
Thanks for the addict and pretty sure, that's one of some more user friendly alternatives! Just shared the code because it's on my "favorites list" for needs on my projects . Sorry not mention something more user-friendly also but, @unusual_research make a good one here for us!The code solution provided by @kalil is also viable and does the thing.
If you're looking for a more user-friendly, no-code solution:
- Install and activate the Custom Post Type UI free plugin.
- Go to CPT UI - Add/Edit Post Types menu >Edit Post Types tab (left img )
- Select post type you want to change from the dropdown on the new tab
- Edit what you need and save
To migrate the current posts and their content be sure to check the box before Migrate posts to newly renamed post type?
MAKE SURE TO READ AND UNDERSTAND EVERYTHING BELOW THE SLUG INPUT FIELD
It's spelled "route" , not "rute" in English
- Go to Settings > Permalinks menu (right img ) and click "Save Changes" to trigger a permalink refresh.
Personally, I would create new post type, export all existing posts from the current post type and re-import them to my the fresh one. This is a cleaner solution and it's completely independent of any current or future theme code or settings that work with it's own registered CPT.
Highly recommended
USE A CHILD THEME FOR ALL CUSTOM WORK THAT MODIFIES THEME CONTENT/STRUCTURE. This is useful to prevent potential conflicts and overwrites caused by future theme updates.
For example: If you use VS Code to search and replace in the theme-folder, all your changes will be overwritten when you update the theme.
Good luck !
=
Well, I'd still create a completely new custom post type and work it from there. But that depends on the theme OP is using.Thanks for the addict and pretty sure, that's one of some more user friendly alternatives! Just shared the code because it's on my "favorites list" for needs on my projects . Sorry not mention something more user-friendly also but, @unusual_research make a good one here for us!
We get it, advertisements are annoying!
However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.
If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.