I’ve used this method a bunch of times and have decided it’s high time to document the process. It’s my favorite method for using colorbox with the built-in WordPress gallery. Detailed steps after the jump.
Put all three into a directory named colorbox inside of your theme folder’s js/ directory.
$(document).ready(function(){
$('.gallery a:has(img)').colorbox();
$(".colorbox").colorbox();
});
This will be sure that the colorbox script is used in the image gallery and also on any link that has the class “colorbox”, so you can add it to other images and links.
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/js/colorbox/colorbox.css" type="text/css" media="screen" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/colorbox/jquery.colorbox-min.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/functions.js"></script>
I usually like to put the colorbox css before my main theme’s stylesheet, in case I want to make any simple modifications to the defaults. Also, be sure to call in your javascript in the above order.
That’s it, except perhaps for some additional stylesheet-tweaking.
Some examples:
My portfolio
Congregation Emanuel