Skip to content

Instantly share code, notes, and snippets.

@amElnagdy
Created November 24, 2016 13:19
Show Gist options
  • Save amElnagdy/ca5d509a4bfc7e527be1857ccce1a554 to your computer and use it in GitHub Desktop.
Save amElnagdy/ca5d509a4bfc7e527be1857ccce1a554 to your computer and use it in GitHub Desktop.
A simple code to enable Divi settings metabox on custom 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