Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayeenulislam/3fd880e99fae78a76edc to your computer and use it in GitHub Desktop.
Save mayeenulislam/3fd880e99fae78a76edc to your computer and use it in GitHub Desktop.
jQuery - show/hide WP meta boxes on post type selection. To make things work, you have to assure the jQuery is turned on, and you have to enqueue the scripts using `admin_enqueue_scripts()`
jQuery(document).ready(function($) {
$('body.post-new-php #formatdiv input[id="post-format-gallery"], body.post-new-php #formatdiv input[id="post-format-video"]').change(function(){
$('.news-head-div').slideUp();
$('.news-highlight-div').slideUp();
$('#news-position').slideUp();
$('#categorydiv').slideUp();
});
$('body.post-new-php #formatdiv input[id="post-format-0"]').change(function(){
$('.news-head-div').slideDown();
$('.news-highlight-div').slideDown();
$('#news-position').slideDown();
$('#categorydiv').slideDown();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment