Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
have you tried all these possibilities in console? –  M-R Dec 13 '12 at 6:42
    
Yes..It is not working..It is very odd. –  Codex Meridian Dec 13 '12 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 '12 at 6:53
    
No errors, I have it working. Thanks for your help. –  Codex Meridian Dec 13 '12 at 7:23
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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