Jon_D

Isotope + Wordpress

Oct 28th, 2013
1,063
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.45 KB | None | 0 0
  1.             <div class="thirteen columns">
  2.  
  3.                 <div id="options" class="clearfix">
  4.  
  5.                     <?php
  6.                         // Get Portfolio Catagories
  7.                         $cats = get_terms('project_field');
  8.                         // Show filter if catagories exist
  9.                         if($cats[1] !=' ') {
  10.                     ?>
  11.  
  12.                     <!-- Portfolio Filter -->
  13.  
  14.                     <ul id="filters" class="option-set clearfix" data-option-key="filter">
  15.                         <li><a href="#filter" data-option-value="*" class="selected">All</a></li>
  16.                         <?php foreach($cats as $cat): ?>
  17.                         <li><a href="#filter" data-option-value=".<?php echo $cat->slug; ?>" class="selected"><?php echo $cat->name; ?></a></li>
  18.                         <?php endforeach; ?>
  19.                     </ul>
  20.  
  21.                     <!-- Portfolio Filter Ends -->
  22.  
  23.                     <?php } ?>
  24.  
  25.                 </div>
  26.  
  27.                 <div id="container" class="clearfix">
  28.  
  29.                     <?php
  30.                         // Get Post Type ==> portfolio
  31.                         query_posts(array(
  32.                             'post_type' => 'portfolio',
  33.                             'posts_per_page' => -1
  34.                             ));
  35.  
  36.                         while(have_posts()): the_post();
  37.  
  38.                         $terms= get_the_terms(get_the_id(), 'project_field');
  39.                     ?>
  40.  
  41.                     <div class=".element <?php if($terms) { foreach ($terms as $term) { echo $term->slug . ' ';}}?>" data-catagory="<?php if($terms) { foreach ($terms as $term) { echo $term->slug . ' ';}}?>">
  42.                         <img src="<?php the_field('project_cover'); ?>">
  43.                     </div>
  44.  
  45.                     <?php endwhile; ?>
  46.  
  47.                 </div>
  48.  
  49.                 <script type='text/javascript' src='http://localhost/wp-content/themes/idea/js/jquery.isotope.min.js?ver=3.7'></script>
  50.                 <script type='text/javascript' src='http://localhost/wp-content/themes/idea/js/jquery-1.10.2.js?ver=3.7'></script>
  51.                 <script>
  52.                     var $j = jQuery.noConflict();
  53.  
  54.                     $j(document).ready(function() {
  55.  
  56.                         $(function(){
  57.                          
  58.                           var $container = $('#container');
  59.  
  60.                           $container.isotope({
  61.                             itemSelector : '.element',
  62.                             layoutMode: 'fitRows',
  63.                             animationEngine: 'best-available'
  64.                           });
  65.                          
  66.                          
  67.                           var $optionSets = $('#options .option-set'),
  68.                               $optionLinks = $optionSets.find('a');
  69.  
  70.                           $optionLinks.click(function(){
  71.                             var $this = $(this);
  72.                             // don't proceed if already selected
  73.                             if ( $this.hasClass('selected') ) {
  74.                               return false;
  75.                             }
  76.                             var $optionSet = $this.parents('.option-set');
  77.                             $optionSet.find('.selected').removeClass('selected');
  78.                             $this.addClass('selected');
  79.                      
  80.                             // make option object dynamically, i.e. { filter: '.my-filter-class' }
  81.                             var options = {},
  82.                                 key = $optionSet.attr('data-option-key'),
  83.                                 value = $this.attr('data-option-value');
  84.                             // parse 'false' as false boolean
  85.                             value = value === 'false' ? false : value;
  86.                             options[ key ] = value;
  87.                             if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) {
  88.                               // changes in layout modes need extra logic
  89.                               changeLayoutMode( $this, options )
  90.                             } else {
  91.                               // otherwise, apply new options
  92.                               $container.isotope( options );
  93.                             }
  94.                            
  95.                             return false;
  96.                           });
  97.  
  98.                          
  99.                         });
  100.                     }
  101.                   </script>
  102.  
  103.             </div>
Advertisement
Add Comment
Please, Sign In to add comment