Im trying to use Isotope(http://isotope.metafizzy.co/) to filter my WordPress posts,
http://i44.tinypic.com/fco55k.jpg this is how my site looks like, i would like to filter posts depending on a post category so i need to add a class name to each post and then filter it using isotope
<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>
those are the names of my categories, and then i would like to add class name of a post depending on a category he is in.
<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="https://wordpress.stackexchange.com/questions/44963/<?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>
and javascript im using
<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>