0

I am adding meta box via add_meta_box hook but it is not showing in the admin panel, I double check the source code and it seems hidden because of this line:

<div class="postbox-container" id="postbox-container-2" style="display: none;">

These are all my attempts to remove this display:none but all are not working:

a.) Using CSS like:

#postbox-container-2 {display:block;}

b.) Using jQuery like:

$('#postbox-container-2').css('style','');

OR

$('#postbox-container-2').show();

OR

$('#postbox-container-2').css('display','block');

OR

$('#postbox-container-2').removeAttr()('display');

How to make that div appear? Thank you for any tips.

4
  • have you tried all these possibilities in console?
    – M-R
    Dec 13, 2012 at 6:42
  • Yes..It is not working..It is very odd. Dec 13, 2012 at 6:45
  • You got any errors? Use jQuery instead of $ (WordPress load jQuery in no-conflict mode). Does jQuery('#postbox-container-2') return any element?
    – M-R
    Dec 13, 2012 at 6:53
  • No errors, I have it working. Thanks for your help. Dec 13, 2012 at 7:23

1 Answer 1

0

This did the trick, in jQuery:

    //get page title
var edit_title_page=$("html head title").text();

//Confirm if this is right Edit page

if (edit_title_page.indexOf("Edit Form") >= 0) {
    $('#postbox-container-2').removeClass("postbox-container");
    $('#postbox-container-2').css('width','100%');
    $('#postbox-container-2').css('float','left');
    $('#mymetaboxID').show();

}

It will first check for edit page title, if it's on the right page, remove the post-box container containing the display none, then apply a new css styling.

Finally show the meta box added using add_meta_box, this works for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.