-
-
Save atsea/948e22e51a18da7fc778952f6f88f17b to your computer and use it in GitHub Desktop.
Enables custom post types in Divi Builder
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 | |
/** | |
ENABLE CUSTOM POST TYPES WITHIN DIVI BUILDER | |
@author Nagdy at wpcolt.com | |
@see https://wpcolt.com/enable-divi-visual-builder-on-custom-post-types/ | |
*/ | |
add_filter('et_builder_post_types', 'divicolt_post_types'); | |
add_filter('et_fb_post_types','divicolt_post_types' ); // Enable Divi Visual Builder on the custom post types | |
function divicolt_post_types($post_types) | |
{ | |
foreach (get_post_types() as $post_type) { | |
if (!in_array($post_type, $post_types) and post_type_supports($post_type, 'editor')) { | |
$post_types[] = $post_type; | |
} | |
} | |
return $post_types; | |
} | |
add_action('add_meta_boxes', 'divicolt_add_meta_box'); | |
function divicolt_add_meta_box() | |
{ | |
foreach (get_post_types() as $post_type) { | |
if (post_type_supports($post_type, 'editor') and function_exists('et_single_settings_meta_box')) { | |
$obj= get_post_type_object( $post_type ); | |
add_meta_box('et_settings_meta_box', sprintf(__('Divi %s Settings', 'Divi'), $obj->labels->singular_name), 'et_single_settings_meta_box', $post_type, 'side', 'high'); | |
} | |
} | |
} | |
add_action('admin_head', 'divicolt_admin_js'); | |
function divicolt_admin_js() | |
{ | |
$s = get_current_screen(); | |
if (!empty($s->post_type) and $s->post_type != 'page' and $s->post_type != 'post') { | |
?> | |
<script> | |
jQuery(function ($) { | |
$('#et_pb_layout').insertAfter($('#et_pb_main_editor_wrap')); | |
}); | |
</script> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment