WordPress ThickBox – Use modal lightboxes in the admin area

If you want to use a modal lightbox for your plugin's admin page in WordPress, you can use ThickBox. WordPress is already using ThickBox, so it is really easy to implement.

See the WordPress guide to ThickBox.

To implement the ThickBox, you need to do the following:

  1. You have to load the ThickBox. You do this by calling:
    <?php add_thickbox(); ?>
  2. Then create a link that triggers the ThickBox:
    <a href="#TB_inline?width=600&height=550&inlineId=my-content-id" class="thickbox">View my inline content!</a>
  3. Create your box:
    <div id="my-content-id" style="display:none;">
         <p>
              This is my hidden content! It will appear in ThickBox when the link is clicked.
         </p>
    </div>
    

 

You can set some other settings too. You can for example set the title, which appears int the top of the modal. You just add title to the link:

<a href="#TB_inline?width=600&height=550&inlineId=my-content-id" class="thickbox" title="MY TITLE HERE!!!">View my inline content!</a>

You can get some more inspiration how to set settings for the ThickBox here.

ms@morningtrain.dk'

Martin Schadegg Rasch Jensen