I am trying to remove a metabox ID from a page ID in the admin screen. So I have coded the following:
function ag_remove_cmb_metaboxes() {
global $post;
$id = $post->ID;
if ($id == 21) { ?>
<script type="text/javascript">
jQuery(document).ready(function($){
jQuery('#test_metabox_img') .hide();
});
</script>
<?php }
}
add_action( 'admin_head', 'ag_remove_cmb_metaboxes' );
It is working fine but an error is showing in the widget.php page. Error code is:
Notice: Trying to get property of non-object in E:\xampp\htdocs\speechcare\wp-content\themes\cutedoctor\core\helpers.php on line 56
Can anyone please explain why this error is showing and what I am doing wrong? Thanks in advance.