Last active
November 27, 2022 02:07
-
-
Save renventura/062edef103469b1177bc to your computer and use it in GitHub Desktop.
Remove the Projects Post Type from Divi by Elegant Themes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //* Mind this opening php tag | |
/** | |
* This will hide the Divi "Project" post type. | |
* Thanks to georgiee (https://gist.github.com/EngageWP/062edef103469b1177bc#gistcomment-1801080) for his improved solution. | |
*/ | |
add_filter( 'et_project_posttype_args', 'mytheme_et_project_posttype_args', 10, 1 ); | |
function mytheme_et_project_posttype_args( $args ) { | |
return array_merge( $args, array( | |
'public' => false, | |
'exclude_from_search' => false, | |
'publicly_queryable' => false, | |
'show_in_nav_menus' => false, | |
'show_ui' => false | |
)); | |
} |
To remove the post type project, just add a blank function named et_pb_register_posttypes in your functions.php. It's works well in a child theme
function et_pb_register_posttypes() {
// nothing - to remove post type : project
}
To remove the front builder from admin bar menu, if the page builder it not used, I've put the following code to my functions
function remove_et_front_editor_bar_menu() {
if ( ! et_pb_is_pagebuilder_used( get_the_ID() ) ) {
remove_action( 'admin_bar_menu', 'et_fb_add_admin_bar_link', 999 );
}
}
add_action( 'admin_bar_init', 'remove_et_front_editor_bar_menu' );
THANK YOU!! Worked for me!
To remove the post type project, just add a blank function named et_pb_register_posttypes in your functions.php. It's works well in a child theme
function et_pb_register_posttypes() { // nothing - to remove post type : project }
To remove the front builder from admin bar menu, if the page builder it not used, I've put the following code to my functions
function remove_et_front_editor_bar_menu() { if ( ! et_pb_is_pagebuilder_used( get_the_ID() ) ) { remove_action( 'admin_bar_menu', 'et_fb_add_admin_bar_link', 999 ); } } add_action( 'admin_bar_init', 'remove_et_front_editor_bar_menu' );
This worked great for me. At least from what I can tell so far. I'll try to remember to update this thread if I do come across any issues.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
thanks for the
public=> false
idea. I struggled to remove that CPT as I want my very own Projects Type.I have two additions:
public => false
to fully remove the CPT the good wat(1) YES. Never ever disable the internal Project post type of Divi. You will run into problems with their cached templates - or in other words problems hard to reproduce for many people.
For example you might get a modal window
Divi Builder Timeout
together with some failed ajax requests in your console - if you have php's notice log level enabled.But you will get this error only when divi's templates aren't yet cache in your local storage. Long story short:
(2) YES AGAIN. Trust @ActionScripted and hide them with public=> false instead of removing them. And if you do so- at the moment it is not sufficient anymore to set only public to false. Divi has changed to a very explicit post type definition which is cancels the inheritance chain the public property. You have to set all implicit fields to false in order to hide it also in the navigation and other places. That's what's working with Divi 2.7.5 (06/2016)
if you want to know why exactly those fields read this:
https://codex.wordpress.org/Function_Reference/register_post_type
Good luck