我想用同位素(http://isotope.metafizzy.co/) 要筛选我的Wordpress帖子,http://i44.tinypic.com/fco55k.jpg 这就是我的网站看起来的样子,我想根据帖子类别过滤帖子,所以我需要为每个帖子添加一个类名,然后使用同位素对其进行过滤
<li><a href="#" data-filter="*">show all</a></li>
<li><a href="#" data-filter=".design">design</a></li>
<li><a href="#" data-filter=".typo">typography</a></li>
这些是我的类别名称,然后我想根据他所在的类别添加一篇文章的类名。<div id="main">
<?php
$args = array(\'orderby\' => \'rand\' );
$random = new WP_Query($args); ?>
<?php if(have_posts()) : ?><?php while($random->have_posts()) : $random->the_post(); ?>
<a href="<?php the_permalink() ?>"> <div id="img" class="<?php $category = get_the_category();
echo $category[0]->cat_name; ?>">
<?php
the_post_thumbnail();?>
<h1><?php the_title(); ?></h1>
</div></a>
和javascript im使用 <script type="text/javascript">
jQuery(window).load(function(){
jQuery(\'#main\').isotope({
masonry: {
columnWidth: 20
},
});
$(\'#filters a\').click(function(event){
var selector = $(this).attr(\'data-filter\');
$(\'#main\').isotope({ filter: selector });
return false;
});
});
</script>