SHARE
TWEET

Untitled

a guest Apr 20th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <form method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
  2. <?php
  3. $taxonomy_names = array('typesbijoux','matieres','annees','saisons');//je declare mes taxonomies
  4. $custom_post_type = 'bijoux';
  5.  
  6. foreach ($taxonomy_names as $name){ //je compte mes taxonomies declarées
  7. $objects_taxos= get_object_taxonomies($custom_post_type,$name);
  8. }
  9.  
  10. foreach ($objects_taxos as $object_taxo){
  11. $names_taxos = $object_taxo->label;
  12. $taxName= $object_taxo->name;?>
  13.  
  14. <div class="checkbox"><h2><?php echo $names_taxos;?></h2></br>
  15.                 <?php $taxonomys = get_terms($taxName); /* recuperer terme de taxo a chaque tour de boucle */
  16.             if(!is_wp_error($taxonomys) && count($taxonomys)):
  17.                 foreach($taxonomys as $taxonomy):
  18.                 $tax_posts = get_posts(array('post_type' => get_post_type($custom_post_type), 'taxonomy' => $taxName, 'term' => $taxonomy->slug ) );
  19.             if($tax_posts):?>
  20.                 <label><input type="checkbox" name="<?php echo $taxName?>[]" value="<?php echo $taxonomy->slug;?>"><?php echo $taxonomy->name; ?></label><br>
  21.             <?php endif;endforeach;?> </div>;<?php endif; /* ajouter checked*/?>
  22. <?php  
  23. wp_reset_postdata();
  24. }?>
  25. <input type="submit" value="Filtrer" />
  26. </form>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top