The Divi Theme come with its own custom post type called “Projects,” which is designed to integrate with the Portfolio and Filterable Portfolio modules. Although this feature is great for showcasing projects, its name might feel a bit restrictive for anyone wanting to use the post type for other things. Rather than adding a new post type, you may want to just rename the Projects post type. In this tutorial, I will show you how to rename and reuse the default Divi Projects custom post type that comes by default with Divi.
▶️ Please watch the video above to get all the exciting details! 👆
Add A PHP Code Snippet To Rename The Divi Projects Post Type
To rename Divi Projects custom post type to something else, you can use the PHP code snippet below and modify specific text in the code. We have instructions below for where to paste PHP code if you are not familiar with it. I also have comments in the code – it is very important to only change the text within the quotation marks that are highlighted by the comments. Please remember to always be careful, as PHP can cause issues if not implemented properly. After adding this snippet to your site and customizing the labels, you can refresh the dashboard and the Projects menu will be renamed.
Where To Paste The PHP Code
1. Divi Assistant
If you are using our Divi Assistant plugin, simply paste the code in the PHP tab in the custom code window in the Divi Visual Builder.
2. Child Theme
If you are using a child theme, paste this code into the functions.php file. If you don't have a child theme, you can generate a child theme directly on your site or download our free child theme.
3. Code Snippet Plugins
Otherwise, install a dedicated code snippet plugin, create a new snippet, and paste this code into the PHP code editor.
If you need help understanding where to paste the code, please check out our complete guide about where to add custom PHP code snippets in Divi.
function maybe_filter_project_args()
{
// Update variables value in code to rename the post type
$singular_name = 'Project'; // Update this variable to change the singular name of the post type.
$plural_name = 'Projects'; // Update this variable to change the plural name of the post type.
$slug = 'projects'; // Update this variable to change the slug of the post type.
$menu_icon = 'dashicons-admin-post';
register_post_type('project', [
'labels' => [
'name' => $plural_name,
'singular_name' => $singular_name,
'add_new_item' => sprintf('Add New %s', $singular_name),
'edit_item' => sprintf('Edit %s', $singular_name),
'new_item' => sprintf('New %s', $singular_name),
'all_items' => sprintf('All %s', $plural_name),
'view_item' => sprintf('View %s', $singular_name),
'search_items' => sprintf('Search %s', $plural_name),
],
'menu_icon' => $menu_icon,
'has_archive' => true,
'hierarchical' => true,
'public' => true,
'rewrite' => [
'slug' => $slug,
],
]);
// Rename Project Category Labels and Slug
$category_singular_name = 'Project Category'; // Update this variable to change the singular name of the category.
$category_plural_name = 'Project Categories'; // Update this variable to change the plural name of the category.
$category_slug = 'project_category'; // Update this variable to change the slug of the category.
register_taxonomy('project_category', array('project'), [
'hierarchical' => true,
'labels' => [
'name' => sprintf('%s', $category_plural_name),
'singular_name' => sprintf('%s', $category_singular_name),
'search_items' => sprintf('Search %s', $category_plural_name),
'all_items' => sprintf('All %s', $category_plural_name),
'parent_item' => sprintf('Parent %s', $category_singular_name),
'parent_item_colon' => sprintf('Parent %s:', $category_singular_name),
'edit_item' => sprintf('Edit %s', $category_singular_name),
'update_item' => sprintf('Update %s', $category_singular_name),
'add_new_item' => sprintf('Add New %s', $category_singular_name),
'new_item_name' => sprintf('New %s Name', $category_singular_name),
'menu_name' => sprintf('%s', $category_plural_name),
'not_found' => sprintf('You currently don\'t have any %s.', $category_plural_name),
],
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'show_in_rest' => true,
'rewrite' => [
'slug' => $category_slug,
'with_front' => true,
],
]);
// Rename Project Tag Labels and Slug
$tag_singular_name = 'Project Tag'; // Update this variable to change the singular name of the tag.
$tag_plural_name = 'Project Tags'; // Update this variable to change the plural name of the tag.
$tag_slug = 'project_tag'; // Update this variable to change the slug of the tag.
register_taxonomy('project_tag', array('project'), [
'hierarchical' => true,
'labels' => [
'name' => sprintf('%s', $tag_plural_name),
'singular_name' => sprintf('%s', $tag_singular_name),
'search_items' => sprintf('Search %s', $tag_plural_name),
'all_items' => sprintf('All %s', $tag_plural_name),
'parent_item' => sprintf('Parent %s', $tag_singular_name),
'parent_item_colon' => sprintf('Parent %s:', $tag_singular_name),
'edit_item' => sprintf('Edit %s', $tag_singular_name),
'update_item' => sprintf('Update %s', $tag_singular_name),
'add_new_item' => sprintf('Add New %s', $tag_singular_name),
'new_item_name' => sprintf('New %s Name', $tag_singular_name),
'menu_name' => sprintf('%s', $tag_plural_name),
'not_found' => sprintf('You currently don\'t have any %s.', $tag_plural_name),
],
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'show_in_rest' => true,
'rewrite' => [
'slug' => $tag_slug,
'with_front' => true,
],
]);
}
add_action('init', 'maybe_filter_project_args');
How To Rename The Projects Custom Post Type Using Divi Assistant
Here are the simple steps to rename the Projects custom post type using our popular Divi Assistant plugin:
- Install and activate the Divi Assistant plugin
- Click on the Utility Helper tab and the Post Types subtab
- Enable the setting
I hope that is easy enough for you! 😉
0 Comments