サポート » 使い方全般 » javascriptsが動作しない

  • wordpress初心者の者です。
    wordpresでwookmarkというjqueryを使用したいのですが、全く動作しなくて困ってます。
    http://bosssato.hatenablog.com/entry/20120701/1341121636

    以下の通りヘッダーにリンク及びjavascriptsのコードを貼付けております。
    何か間違っている点などありますでしょうか?
    お教示いただけたら、助かります。

    以下ソース

    <?php wp_enqueue_style(‘reset’, get_bloginfo(‘template_url’) . ‘/menu/css/reset.css’); ?>
    <?php wp_enqueue_style(‘style’, get_bloginfo(‘template_url’) . ‘/menu/main/css/style.css’); ?>
    <?php wp_enqueue_style(‘main’, get_bloginfo(‘template_url’) . ‘/menu/css/main.css’); ?>
    <?php wp_enqueue_script(‘name1’, get_bloginfo(‘template_directory’).’/menu/libs/jquery.min.js’, array(‘jquery’));?>
    <?php wp_enqueue_script(‘name2’, get_bloginfo(‘template_directory’).’/menu/jquery.wookmark.js’, array(‘jquery’, ‘wookmark’)); ?>
    <?php wp_enqueue_script(‘name3’, get_bloginfo(‘template_directory’).’/menu/libs/jquery.imagesloaded.js’, array(‘jquery’, ‘imagesloaded’)); ?>

    <?php wp_head(); ?>

    <!– wookmark –>
    <script type=”text/javascript”>
    (function (jQuery){
    jQuery(‘#tiles’).imagesLoaded(function() {
    // Prepare layout options.
    var options = {
    autoResize: true, // This will auto-update the layout when the browser window is resized.
    container: jQuery(‘#main’), // Optional, used for some extra CSS styling
    offset: 2, // Optional, the distance between grid items
    itemWidth: 210, // Optional, the width of a grid item
    fillEmptySpace: true // Optional, fill the bottom of each column with widths of flexible height
    };

    // Get a reference to your grid items.
    var handler = jQuery(‘#tiles li’),
    filters = jQuery(‘#filters li’);

    // Call the layout function.
    handler.wookmark(options);

    /**
    * When a filter is clicked, toggle it’s active state and refresh.
    */
    var onClickFilter = function(event) {
    var item = jQuery(event.currentTarget),
    activeFilters = [];

    if (!item.hasClass(‘active’)) {
    filters.removeClass(‘active’);
    }
    item.toggleClass(‘active’);

    // Filter by the currently selected filter
    if (item.hasClass(‘active’)) {
    activeFilters.push(item.data(‘filter’));
    }

    handler.wookmarkInstance.filter(activeFilters);
    }

    // Capture filter click events.
    filters.click(onClickFilter);
    });
    })(jQuery);
    </script>

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • こんにちは、

    head要素に、書かないでfunctions.phpに以下のように

    /**
     * Proper way to enqueue scripts and styles
     */
    function theme_name_scripts() {
    	wp_enqueue_style( 'style-name', get_stylesheet_uri() );
    	wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
    }
    
    add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );

    http://codex.wordpress.org/Function_Reference/wp_enqueue_script

    書くのが標準的なので、トライしてみてください

    トピック投稿者 9-taro

    (@9-taro)

    nobita 様

    ご回答ありがとうございます。
    全く的外れのことをしていたようですね。
    参考にさせていただきます。
    ご協力感謝します。

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • トピック「javascriptsが動作しない」には新たに返信することはできません。