Skip to content

Instantly share code, notes, and snippets.

@renventura
Last active November 27, 2022 02:07
  • Star 18 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save renventura/062edef103469b1177bc to your computer and use it in GitHub Desktop.
Remove the Projects Post Type from Divi by Elegant Themes
<?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
));
}
@DeltonChilds
Copy link

Thank you, big help. Clients get confused with "projects" and "products" especially when you're trying to train in WP for the first time.

@sokeara
Copy link

sokeara commented Sep 22, 2015

Dear EngageWP,

I copy and past this code:

//* Remove the "project" custom post type in Divi
add_action( 'after_setup_theme','rv_remove_divi_projects' );
function rv_remove_divi_projects() {
remove_action( 'init', 'et_pb_register_posttypes', 0 );
}

into functions.php but it doesn't work, the Projects post type still show in my admin dashboard. Any solutions?

I use Divi Version: 2.5.3.

Thank in advance,
Sokeara

@yudiqing
Copy link

yudiqing commented Oct 4, 2015

Hi, use this one instead:

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;

@ActionScripted
Copy link

The snippets above may work, they may not. Divi Builder has the Project custom type deeply embedded and I'd suggest simply hiding it to avoid any potential issues. The following will hide the Project type in search and admin (see register_post_type on the WP Codex for more information). Tested and working in WordPress 4.4 with Divi Builder 1.1.3:

/**
 * Hide Divi Builder "project" type
 */
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
  ));
}

And while we're sharing helpful Divi Builder snippets, here's a bonus one to adjust the list of supported post types. (Supported post types show the "Use the Divi Builder" button.)

/**
 * Adjust Divi Builder supported types
 */
add_filter('et_builder_post_types', 'mytheme_et_builder_post_types', 10, 1);
function mytheme_et_builder_post_types($types_array) {
  if (!in_array('some_custom_type', $types_array)) {
    $types_array []= 'some_custom_type';
  }
  return $types_array;
}

The absolute lack of documentation along with some of the mandatory stuff like the Projects custom type for Divi Builder is absurd. If you're reading this it wouldn't hurt to take some time to visit the ET website and add your voice to those asking for docs and adjustments to the plugin.

@georgiee
Copy link

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:

  1. The bad way: What happens when you prevent divi from registering the CPT and
  2. The good way: What you need to add in addition to 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.
screen shot 2016-06-14 at 15 04 41

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)

<?php
//Divi adjustments

//hide - not removing - the internal prohect post type.
//By hidign it we prevent any problems as this CPT is deep integrated in divi
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
  ));
}

if you want to know why exactly those fields read this:
https://codex.wordpress.org/Function_Reference/register_post_type

If no value is specified for exclude_from_search, publicly_queryable, show_in_nav_menus, or show_ui, they inherit their values from public.

Good luck

@oloynet
Copy link

oloynet commented Oct 11, 2016

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' );

@kileyohl
Copy link

THANK YOU!! Worked for me!

@chris-hotchkiss
Copy link

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