I would like to add thickbox for the template which I develop to WordPress. At this time I'm trying with a clean template that have only header.php, footer.php,index.php, and functions.php.

I've included the <?php wp_head(); ?> into header.php and the <?php wp_footer(); ?> into footer.php.

I've included the wp_head like this:


I've changed the gallery link classes to thickbox with this code in functions.php

<?php add_filter( 'wp_get_attachment_link', 'sant_prettyadd');

function sant_prettyadd ($content) {
    $content = preg_replace("/<a/","<a class=\"thickbox[slides]\"",$content,1);
    return $content;

When I'm clicking on to a gallery image it should open with thickbox but it opens the imagefile only.

3 Answers 3


You need to use the wp_enqueue_script function (in your functions.php file) to call the relevant scripts you need. It allows for both built-in libraries and to add any custom that you're including in your theme.

  • Okay I enquaue the scripts from functions. Do I do right if just include the enquaue or should I use init? Jan 4, 2012 at 17:49
  • If you're loading multiple, or using conditionals (i.e. only load script X on single posts and script Y on the home page) than an init is a better bet. But either way you should be fine.
    – Norcross
    Jan 4, 2012 at 17:54
  • Thank you very much it's succesfull .. I'm lucky with ya! Jan 4, 2012 at 18:23

All you need to do is a simple call in your functions.php:

add_action( 'wp_enqueue_scripts', 'add_thickbox' );

That’s it. WordPress will now enqueue jQuery and the thickbox script. By default, linked images aren’t thickboxy yet. You need to:

  1. Add a class thickbox to the links manually/per PHP, or
  2. Use a second script to add these classes automagically.

Sample code for footer.php:

jQuery('a img.size-medium').parent().addClass('thickbox').attr('rel', 'page');

This code adds the class thickbox to all links around medium sized images, and it groups these links to enable the next/prev navigation links.

Now you get a basic thickbox with translated navigation links:

enter image description here

Since this is a script managed by the core it is not keyboard user friendly: The arrow keys don’t do anything. If you need a more usable solution – take a plugin.

Another note: Thickbox may be removed sooner or later from the core. See Ticket 10955.


Hi can any one help me to resolve my problem::

Here it my code

<a href="'. site_url("wp-admin/admin-ajax.php?action=user_avatar_add_photo&step=1&uid="). $myUID . '&TB_iframe=true&width=720&height=450" title="Upload and Crop an Image to be Displayed" >' . ( 'Update Picture','wp-members' ) . '</a>

this piece of code i'm trying to use in Wp-admin profile it is working fine but.. there is a problem... i.e while I try to chance the user avatar from front end TB_ifram is not popping up... it is spreading to whole webpage...

here it's image: enter image description here here i need to popup the TB_Ifram content frame from the front end... plz give me suggestion that would be great to you..


  • Welcome to WordPress SE. If you have a question, please start a new question rather than posting it as an answer on another question. Thanks!
    – Dan
    Mar 21, 2014 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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