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.

How can get a modal window to work from within the wordpress admin?

I want to create a modal window that will work from a meta box within the wp-admin.

Any ideas?

share|improve this question
1  
50% is pretty low - please remember to return to your old questions and accept correct answers. It takes them off the 'unanswered' pile and helps others find solutions more easily. People will also be more willing to offer answers if they know that the OP will respond to them. :) –  Stephen Harris Apr 10 '12 at 15:47

2 Answers 2

up vote 4 down vote accepted

Give the anchor a class of thickbox and make sure that the thickbox script is enqueued on your admin page using add_thickbox

add_thickbox();

and

<a href="your url" class="thickbox">click here</a>

You can see what add_thickbox does here:

http://hitchhackerguide.com/2011/02/11/add_thickbox/

share|improve this answer
1  
I think it might not be necessary to enqueue thickbox: it is automatically (at least in some instances) enqueued on a post edit page. See add_thickbox() too. –  Stephen Harris Apr 10 '12 at 16:05
    
So how would I populate it with html? –  Shae Apr 10 '12 at 17:41
    
Note your url, it loads the URL of the anchor into an iframe –  Tom J Nowell Apr 10 '12 at 18:48

To use Thickbox for inline modal windows you can use the following code.

<?php add_thickbox(); ?>

<a href="#TB_inline?width=600&height=550&inlineId=modal-window-id" class="thickbox">Modal Me</a>

<div id="modal-window-id" style="display:none;">
    <p>Lorem Ipsum sit dolla amet.</p>
</div>

http://codex.wordpress.org/ThickBox

share|improve this answer

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.