Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

filter data in wordpress

jQuery(window).on("load", function() {
	  var $grid = jQuery('.port-grid1').isotope({
		itemSelector: '.grid-port1',
		percentPosition: true,
		masonry: {
		  // use outer width of grid-sizer for columnWidth
		  columnWidth: '.grid-port1'
		}
	  });

	  jQuery('.item-filter').on('click', '.gallery-btn', function () {
		var filterValue = $(this).attr('data-filter');
		jQuery('.port-grid').isotope({
		  filter: filterValue
		});
	  });
	  
	  jQuery('select.item-filter').on('change', function() {
	  	var filterValue = $(".item-filter option:selected").attr("data-filter")
		jQuery('.port-grid').isotope({
		  filter: filterValue
		});
	  });
});

<select class="item-filter item-filter-v2 list-inline">
                <option class="active gallery-btn" data-filter=".All">All genres</option>
                <?php	
				foreach ($tax_terms_book  as $tax_term) {
					$tax_term_id = $tax_term->term_id; 									
					?>
					<option class="gallery-btn" <?php  echo "data-filter='.bookg-$tax_term_id'"; ?>><?php echo $tax_term->name; ?></option>
				<?php
				} 
				?>	
            </select>
                  
                  
                    <div class="col-md-4 grid-port1 grid-port All <?php foreach ($portfolio_terms_id as $portfolio_term_id) { echo "bookg-"; echo $portfolio_term_id; echo " "; }?>">
 
PREVIOUS NEXT
Tagged: #filter #data #wordpress
ADD COMMENT
Topic
Name
9+6 =