This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Adding Masonry Layout to JS

  • Creator
    Topic
  • #6436
    sharonq
    Participant

    I would like to add masonry to Jumpstart but am worried I will break something.

    I am following this tutorial: http://www.wplover.com/1818/tutorial-using-jquery-masonry-with-wordpress/

    This is the first step:

    First we enqueue jQuery and call the Masonry JS script in the theme’s header.php file.
    
    <?php wp_enqueue_script('jquery'); ?>
    <?php wp_head(); ?>
    <script language="javascript" type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.masonry.min.js"></script>
    
    Make sure that wp_enqueue_script appears before wp_head, and the script call appears after it. Here’s a more detailed article on how to correctly enqueue jQuery in WordPress. My Masonry JS is located in a /js folder, yours might be different.

    Your warning says that I should not edit the header.php file but use hooks instead…

    What do I hook? and how?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #6439
    sharonq
    Participant

    I found a plugin called Custom Javascript Editor – and am using it to load Masonry… and am trying to figure out if it is all I need to load the masonry script…

    #6456
    Jason Bobich
    Keymaster

    Hello,

    Just in general, no matter what theme you’re using, calling javascript files in header.php is not the way to do it. So, if you have a tutorial that’s telling you to do that, it may not be a good one to follow.

    This is how you load scripts in WordPress from the Codex: http://codex.wordpress.org/Function_Reference/wp_enqueue_script

    And here’s a more in-depth article from a trusted source: http://wpcandy.com/teaches/how-to-load-scripts-in-wordpress-themes/

    I found a plugin called Custom Javascript Editor – and am using it to load Masonry… and am trying to figure out if it is all I need to load the masonry script…

    And sure, if you want to use a plugin to do this, you can do that, as well. But I’d say that simply including the Masonry script is only going to be the beginning of implementing it. I think you’re going to have to spend on some time on the site’s documentation learning how it works.

    http://masonry.desandro.com/

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.