Removing Pie Calendar's meta boxes and sidebar controls
Note that we do not advise removing Pie Calendar's built-in meta boxes or sidebar controls. There could be unintended side effects, and you won't be able to use the recurrence feature if you do this. We do not provide support for issues that result from using the code snippets provided below.
In some cases, you may want to use custom fields as your start and end dates. If you're doing that and don't need the built-in Pie Calendar controls to be visible, you can remove the built-in Pie Calendar meta boxes and sidebar controls using the following code:
function remove_piecal_metabox() { $post_type = 'post'; // Replace this with the slug of the post you want to remove the meta box on. remove_meta_box('piecalendar-metabox', $post_type, 'normal'); remove_meta_box('piecalendar-metabox', $post_type, 'side'); remove_meta_box('piecalendar-metabox', $post_type, 'advanced'); remove_meta_box('piecalendar-pro-metabox', $post_type, 'normal'); remove_meta_box('piecalendar-pro-metabox', $post_type, 'side'); remove_meta_box('piecalendar-pro-metabox', $post_type, 'advanced'); } add_action('do_meta_boxes', 'remove_piecal_metabox'); function remove_piecal_sidebar_controls() { // Check if we're in the Block Editor $current_screen = get_current_screen(); if ($current_screen && $current_screen->is_block_editor) { ?> <script> console.log('bang1'); wp.domReady(() => { piecalGbVars.explicitAllowedPostTypes = [...piecalGbVars.explicitAllowedPostTypes, 'dummy']; }); </script> <?php } } add_action('admin_footer', 'remove_piecal_sidebar_controls');
Important notes:
- You'll need to update the
$post_type
variable with the slug of the post type you want to remove the meta box on. If you want to remove it on multiple post types, you'll need to runt he remove_meta_box function on each one. - The Block Editor sidebar controls are removed by passing a fake post type into the explicitAllowedPostTypes list when the editor loads. If you want the controls on some posts but not others, you'll need to make sure the post types you want the controls on are in this list.