To change the name of a custom post type, simply replace all instances of the custom post type name with the new name you want to use for your CPT.
Code for creating a custom post type generally includes both a singular and plural name. In this example, the names which need replacing are member and members.
Firstly, lets take a look at the basic PHP code needed to create a custom post type:
And here’s a screen shot showing which names need to be changed.
You can change the names manually or use a code editor like Notepad++ to search, find and replace the name with your new name.
Here’s the 4 instances of the custom post type name which need to be changed:
After you rename your custom post type, go to Settings > Permalinks and re-save your Permalinks.
Here’s an example of the code changed from members to photos.
You may also want to change the menu icon using Dashicons.
Change Existing Custom Post Type Pages
After you’ve changed the name of your CPT, you may also need to change the name of any existing single CPT’s created using the old CPT name:
You can do this using various methods like:
- An SQL Query in phpMyAdmin
- Using a plugin
- Manually using a code editor to open and change a copy of your database SQL file.
Here’s 3 Ways To Change & Convert Different WordPress Post Types