Last active
September 9, 2017 18:58
-
-
Save amitabhaghosh197/2aa8f7ace32000aca901 to your computer and use it in GitHub Desktop.
hide _cmb_metabox_id_from_a_page_id #wordpress #metabox #meta-box
This file contains hidden or 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 | |
/** | |
**Hide a particular metabox id from a page id | |
**Inspirations: | |
** 1. http://www.farinspace.com/page-specific-wordpress-meta-box/ | |
** 2. http://wordpress.stackexchange.com/questions/50732/possible-to-limit-custom-meta-boxes-depending-on-what-page-template-is-used | |
** 3. http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head | |
** I have to hide 'test_image_id' from the page id 38 | |
** So in function.php add | |
****/ | |
function ag_remove_cmb_metaboxes(){ | |
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ; | |
if( $post_id == 38){?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($){ | |
jQuery('#test_image_id') .hide(); | |
}); | |
</script> | |
<?php } | |
} | |
add_action( 'admin_head', 'ag_remove_cmb_metaboxes' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment