Advertisement
firoze

isotop dynamin in wordpress

Jan 7th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.76 KB | None | 0 0
  1. // isotope dynamic in wordpress
  2.  
  3.                 <div class="col-md-12">
  4.                     <div class="total_awesome_project">
  5.                         <div class="project_filter text-center text-uppercase">
  6.                             <!-- Filters -->
  7.                             <?php if(!is_tax()) {
  8.                             $terms = get_terms("portfolio_category"); // This is category post that has been shown in taxonomy
  9.                             $count = count($terms);
  10.                             if ( $count > 0 ){ ?>
  11.                             <ul class="filter_option nav">
  12.                             <li class="active" data-filter="*"><?php  _e('all', 'webdgallery'); ?></li> <!--This is default-->
  13.                             <?php
  14.                             foreach ( $terms as $term ) {
  15.                             echo '<li data-filter=".'.$term->slug.'">'. $term->name .'</li>';
  16.                             } ?> <!--here .'.$term->slug.' is data-filter name/class & '. $term->name .' is title-->   
  17.                             </ul>
  18.                             <?php } } ?>   
  19.                         </div>
  20.                        
  21.                         <div class="all_project">
  22.                             <div class="single_project_wrapper">
  23.                                 <!--here frost_project is post type & 12= how many post that i want to show--->                      
  24.                             <?php query_posts('post_type=frost_project&post_status=publish&posts_per_page=12&paged='.get_query_var('paged')); ?>
  25.                             <?php if(have_posts()) : ?>
  26.                             <?php while (have_posts()) : the_post(); ?>
  27.                            
  28.                                     <!-- this is the code for ?php echo strtolower($tax);?  that has been used below indo the div-->
  29.                                         <?php
  30.                                         $terms = get_the_terms( $post->ID, 'portfolio_category' );  // This is category post that has been shown in taxonomy
  31.  
  32.                                         if ( $terms && ! is_wp_error( $terms ) ) :
  33.                                             $links = array();
  34.  
  35.                                             foreach ( $terms as $term )
  36.                                             {
  37.                                                 $links[] = $term->name;
  38.                                             }
  39.                                             $links = str_replace(' ', '-', $links);
  40.                                             $tax = join( " ", $links );    
  41.                                         else :  
  42.                                             $tax = '';  
  43.                                         endif;
  44.                                         ?>
  45.                                        
  46.                                     <!--here below post_class  will add class or id it has show into functions.php-->
  47.                             <div class="single_all_project <?php echo strtolower($tax);?>" > <!--our portfolio post start & here single_all_project is default class that stay
  48.                             alltime-->
  49.                            
  50.                             <?php if ( has_post_thumbnail()) the_post_thumbnail('portfolio-frost-size'); ?>
  51.                             </div> <!--our portfolio post end-->
  52.                             <?php endwhile; // posibilt to add else statement
  53.                            
  54.                             else:?>
  55.                                 <div class="error-not-found">Sorry, no portfolio entries for while.</div>
  56.                             <?php endif; ?>
  57.                             </div>                     
  58.                         </div>
  59.                     </div>
  60.                 </div>
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. // css for the above code
  68.  
  69. .project_filter{margin-bottom:25px;}
  70. .project_filter ul.filter_option{}
  71. .project_filter ul.filter_option li.active{color:#549dc5;}
  72. .project_filter ul.filter_option li{display:inline-block;color:#2e2e2e;font-size:16px;cursor:pointer;}
  73. .project_filter ul.filter_option li.active:after{}
  74. .project_filter ul.filter_option li:after{content:"/";padding:10px;color: #B4B4B4}
  75. .project_filter ul.filter_option li:last-child:after{display:none;}
  76.  
  77. .all_project{margin-left:-10px;}
  78. .single_project_wrapper{}
  79. .single_all_project{float:left;margin-bottom:10px;margin-left: 10px;}
  80. .single_all_project img{width: 277px;}
  81.  
  82.  
  83.  
  84. // js for the above code isotop active
  85.  
  86.        // portfolio isotope js
  87.         jQuery(document).ready(function () {
  88.             var jQuerycontainer = jQuery('.all_project');
  89.             jQuerycontainer.imagesLoaded(function () {
  90.                 jQuerycontainer.isotope({
  91.                     itemSelector: '.single_all_project',
  92.                     layoutMode: 'fitRows'
  93.                 });
  94.             });
  95.  
  96.             jQuery('.project_filter ul.filter_option li').click(function () {
  97.  
  98.                 jQuery('.project_filter ul.filter_option li').removeClass('active');
  99.                 jQuery(this).addClass('active');
  100.  
  101.                 var selector = jQuery(this).attr('data-filter');
  102.                 jQuerycontainer.isotope({
  103.                     filter: selector
  104.                 });
  105.  
  106.                 return false;
  107.             });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement