Remove Projects Custom Post Type from Divi
March 15, 2017 /
Want to remove projects custom post type from Divi, the premiere theme from Elegant Themes? Sometimes a robust theme like Divi needs to be stripped down a bit. Yes, the Divi WordPress theme from Elegant Themes has a lot of functionality built in. Yes, that’s an understatement. And no, you don’t have to have it all in there in your WordPress backend in your site.
Slap this code into your child theme functions.php file. And bam, your custom post types do a disappearing act like Keyser Söze.
//* Remove the Custom Post Types from the Divi Theme */
if ( ! function_exists( 'et_pb_register_posttypes' ) ) :
function et_pb_register_posttypes() {
global $wp_post_types;
if ( isset( $wp_post_types[ $post_type ] ) ) {
unset( $wp_post_types[ $post_type ] );
return true;
}
return false;
}
endif;
Tested and working in Divi Version: 3.0.37
Or better yet, rename that Projects Custom post type in Divi
//* Rename the Custom Post Types from the Divi Theme */
function rename_diviproject_cpt() {
register_post_type( 'project',
array(
'labels' => array(
'name' => __( 'New Name', 'divi' ),
'singular_name' => __( 'New Name', 'divi' ),
),
'has_archive' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-images-alt2',
'public' => true,
'orderby'=>'title',
'order' => 'DESC',
'posts_per_page' => 50,
'rewrite' => array( 'slug' => 'new-name', 'with_front' => false ),
'supports' => array(),
));
}
add_action( 'init', 'rename_diviproject_cpt' );
Tested and working in Divi Version:3.0.106
Here’s what you’ll see instead of the “Projects” CPT (custom post type):
Posted in WordPress
I spent most of my day trying to figure this out with every other solution I found out there on the web. I am using Toolset Types and with every other possible solution it would not allow me to add a “Projects” CPT.
Although the “Rename” option didn’t work. The “Remove” option did and I was finally able to create a “Projects” CPT as Types kept telling me that the name was already taken. There must be something in recent divi updates that prevents Types from using the “Projects” CPT even if it is renamed as in your example. Thanks for providing me with the remainder of my hair…
Glad to hear this post was some help you. I put it here so I could find it after a similar search that left me partially bald. I’ll have to test the rename code again. I can understand why renaming the custom post type from “Projects” to “Projects” wouldn’t work though.
Tested the rename function and it’s still working in in Divi Version: 3.0.106
The Rename function worked to remove the “project”, I placed the “/”, only that happened to disappear the pages created in “pages”