How to Changing Custom Post Type URL in WordPress.
If you have been troubled on how you can successful change the custom post type URL on your wordpress, here is a simple solution for you, follow the listed steps bellow.
1) Open your FTP or cPpanel and locate folder wp-content. Open it, then open folder “themes” and your theme folder.
2) Now you can open folder “includes” and locate “theme-init.php” file in there. You need to edit this file in any editor.
3) You can locate all post types and slugs in file theme-init.php. All the file content is split into logical block and it will be easy to navigate it. You can also use search feature and just search for slug you need to update.
or if you cant find the post types and slug in the above file, you can check it in functions.php file located in your themes folder. Note that this depends from theme to theme, some developers put that in the functions.php file while some link to another file and insert the code there.
However, most likely it would be in the functions.php file if you cant find it in theme-init.php.
You just need to find the "register_post_type" function for that particular custom post type.
4) Locate and replace post type slug with any slug you need, try not to use spaces. The code should look like:
5) Save the file and test your website.
6) Sometimes you may get 404 error after changing custom post type slug, it is related to permalinks issue. You need to open admin panel, change permalinks structure to default, save website and then revert it to previous state.
Note: Should you see the bellow code in your functions.php
you will have to make changes to this code to avoid your URL being Broken. Replace the code with this.
After uploading make sure you refresh your permalinks.
If you have been troubled on how you can successful change the custom post type URL on your wordpress, here is a simple solution for you, follow the listed steps bellow.
1) Open your FTP or cPpanel and locate folder wp-content. Open it, then open folder “themes” and your theme folder.
2) Now you can open folder “includes” and locate “theme-init.php” file in there. You need to edit this file in any editor.
3) You can locate all post types and slugs in file theme-init.php. All the file content is split into logical block and it will be easy to navigate it. You can also use search feature and just search for slug you need to update.
or if you cant find the post types and slug in the above file, you can check it in functions.php file located in your themes folder. Note that this depends from theme to theme, some developers put that in the functions.php file while some link to another file and insert the code there.
However, most likely it would be in the functions.php file if you cant find it in theme-init.php.
You just need to find the "register_post_type" function for that particular custom post type.
4) Locate and replace post type slug with any slug you need, try not to use spaces. The code should look like:
Code: [Select]
'slug' => 'portfolio-view'
5) Save the file and test your website.
6) Sometimes you may get 404 error after changing custom post type slug, it is related to permalinks issue. You need to open admin panel, change permalinks structure to default, save website and then revert it to previous state.
Note: Should you see the bellow code in your functions.php
Code: [Select]
rewrite = > true
you will have to make changes to this code to avoid your URL being Broken. Replace the code with this.
Code: [Select]
'rewrite' => array( 'slug' => 'binary-options-broker' ),
After uploading make sure you refresh your permalinks.