Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.