Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.79 KB | None | 0 0
  1. function get_terms_dropdown_grade_level($taxonomies, $args){
  2. $myterms = get_terms($taxonomies, $args);
  3. $output ="<select name='activities_grade_level'>";
  4. $output .="<option value='#'>Select grade level</option>";
  5. foreach($myterms as $term){
  6. $root_url = get_bloginfo('url');
  7. $term_taxonomy=$term->taxonomy;
  8. $term_slug=$term->slug;
  9. $term_name =$term->name;
  10. $link = $term_slug;
  11. $output .="<option value='".$link."'>".$term_name."</option>";
  12. }
  13. $output .="</select>";
  14. return $output;
  15. }
  16.  
  17. function get_terms_dropdown_type($taxonomies, $args){
  18. $myterms = get_terms($taxonomies, $args);
  19. $output ="<select name='activities_type'>";
  20. $output .="<option value='#'>Select activity type</option>";
  21. foreach($myterms as $term){
  22. $root_url = get_bloginfo('url');
  23. $term_taxonomy=$term->taxonomy;
  24. $term_slug=$term->slug;
  25. $term_name =$term->name;
  26. $link = $term_slug;
  27. $output .="<option value='".$link."'>".$term_name."</option>";
  28. }
  29. $output .="</select>";
  30. return $output;
  31. }
  32.  
  33. <h2>Filter by</h2>
  34. <form action="<?php bloginfo('url'); ?>" method="get">
  35. <div>
  36. <?php
  37. $taxonomies = array('activities_grade_level');
  38. $args = array('orderby'=>'name','hide_empty'=>false);
  39. $select = get_terms_dropdown_grade_level($taxonomies, $args);
  40. $select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
  41. echo $select;
  42. ?>
  43. <?php
  44. $taxonomies = array('activities_type');
  45. $args = array('orderby'=>'name','hide_empty'=>false);
  46. $select = get_terms_dropdown_type($taxonomies, $args);
  47.  
  48. $select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
  49. echo $select;
  50. ?>
  51. <input type="submit" name="submit" value="filter" />
  52. </div>
  53. </form>
  54.  
  55. $output .="<option value=''>Select taxonomy #1</option>";
  56.  
  57. $output .="<option value='#'>Select taxonomy #1</option>";
  58.  
  59. function get_terms_dropdown_grade_level($taxonomies, $args){
  60. $myterms = get_terms($taxonomies, $args);
  61. $output ="<select name='MYTAXONOMY#1'>"; //CHANGE ME!
  62. $output .="<option value=''>Select taxonomy #1</option>"; //CHANGE ME TO YOUR LIKING!
  63. foreach($myterms as $term){
  64. $root_url = get_bloginfo('url');
  65. $term_taxonomy=$term->taxonomy;
  66. $term_slug=$term->slug;
  67. $term_name =$term->name;
  68. $link = $term_slug;
  69. $output .="<option value='".$link."'>".$term_name."</option>";
  70. }
  71. $output .="</select>";
  72. return $output;
  73. }
  74.  
  75. function get_terms_dropdown_type($taxonomies, $args){
  76. $myterms = get_terms($taxonomies, $args);
  77. $output ="<select name='MYTAXONOMY#2'>"; //CHANGE ME!
  78. $output .="<option value=''>Select taxonomy #2</option>"; //CHANGE ME TO YOUR LIKING! foreach($myterms as $term){
  79. $root_url = get_bloginfo('url');
  80. $term_taxonomy=$term->taxonomy;
  81. $term_slug=$term->slug;
  82. $term_name =$term->name;
  83. $link = $term_slug;
  84. $output .="<option value='".$link."'>".$term_name."</option>";
  85. }
  86. $output .="</select>";
  87. return $output;
  88. }
  89.  
  90. <h3>Filter by:</h3>
  91. <form action="<?php bloginfo('url'); ?>" method="get">
  92. <div>
  93. <?php
  94. $taxonomies = array('MYTAXONOMY#1'); //CHANGE ME!
  95. $args = array('orderby'=>'name','hide_empty'=>false);
  96. $select = get_terms_dropdown_grade_level($taxonomies, $args);
  97. $select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
  98. echo $select;
  99. ?>
  100. <?php
  101. $taxonomies = array('MYTAXONOMY#2'); //CHANGE ME!
  102. $args = array('orderby'=>'name','hide_empty'=>false);
  103. $select = get_terms_dropdown_type($taxonomies, $args);
  104.  
  105. $select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
  106. echo $select;
  107. ?>
  108. <input type="submit" name="submit" value="filter" /> <!--CHANGE VALUE TO YOUR LIKING!-->
  109. </div>
  110. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement