Skip to content

Instantly share code, notes, and snippets.

@hissy
Created March 24, 2012 09:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save hissy/2180431 to your computer and use it in GitHub Desktop.
Save hissy/2180431 to your computer and use it in GitHub Desktop.
Use jQuery Masonry in WordPress Theme
<?php
/**
* Enqueue scripts and styles
*/
function load_scripts() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' );
$dir = get_stylesheet_directory_uri();
wp_enqueue_script( 'jquery-masonry', $dir.'/js/jquery.masonry.min.js', array('jquery'), false, true );
wp_enqueue_script( 'site', $dir.'/js/site.js', array('jquery-masonry'), false, true );
}
add_action( 'wp_enqueue_scripts', 'load_scripts', 50 );
jQuery(window).load(function() {
jQuery('.masonry').masonry({
itemSelector : '.item',
columnWidth : 200,
gutterWidth : 20
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment