2
我正在一個wordpress網站上工作,我想在我的一個頁面中使用jQuery Masonry,但它不起作用。我搜索並嘗試了許多變化,但沒有結果。我想在wordpress中使用砌體,但它似乎不工作
我在這裏:
在header.php中添加此:
<?php wp_enqueue_script("jquery"); ?>
<?php wp_head(); ?>
<script language="javascript" type="text/javascript" src="<?php bloginfo('template_url'); ?>/javascripts/jquery.masonry.min.js"></script>
<script language="javascript" type="text/javascript" src="<?php bloginfo('template_url'); ?>/javascripts/jquery.imagesloaded.js"></script>
<script language="javascript" type="text/javascript">
var $container = $('#masonry-list');
$container.imagesLoaded(function(){
$container.masonry({
itemSelector: '.masonry-item', isAnimated: true
});
});
</script>
</head>
和模板文件(列表objects.php)我有這個標記:
<div id="masonry-list">
<h3> this-is-list-object-page </h3>
<?php $loop = new WP_Query(array('post_type' => 'objects', 'posts_per_page' => -1 , 'orderby' => 'rand')); ?>
<?php while ($loop->have_posts()) : $loop->the_post(); ?>
<div class="masonry-item">
<?php the_title('<a href="' . get_permalink() . '" title="' . the_title_attribute('echo=0') . '" rel="bookmark">', '</a>'); ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail(); ?>
</a>
<?php echo get_the_term_list($post->ID, 'place', 'مکان قرار گیری: ', ', ', ''); ?>
<?php echo get_the_term_list($post->ID, 'category', 'رده: ', ', ', ''); ?>
</div>
<?php endwhile; ?>
</div>
我檢查了所有的.js文件已加載,並且地址沒有問題等。 頁面地址是:http://5.144.130.63/?page_id=69
有人可以幫我解決這個問題嗎?
哇!問題解決了... thanx很多cale_b! – user1781362
爲我添加imagesLoaded記錄,它工作正常。 – user1781362
只是想注意,圖像加載是由砌體作者推薦:) –