Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. $rd_args = (array(
  2. 'ignore_sticky_posts' => 1,
  3. 'orderby' => 'meta_value',
  4.  
  5. 'order' => 'ASC',
  6. 'meta_query' => array(
  7. array(
  8. 'key' => 'brand',
  9. ),
  10. array(
  11. 'key' => 'model',
  12. )
  13. )
  14. ));
  15.  
  16. $rd_query = new WP_Query( $rd_args );
  17.  
  18. $the_query = new WP_Query(array( 'meta_key' => 'votes_count', 'meta_value' => '1' ));
  19.  
  20. $html_out = '';
  21. $html_out = '<select id="office-chooser2" >';
  22. $html_out .= '<option value="none">Select an Office</option>';
  23. $select = '<select id="office-chooser">';
  24. $select .= '<option value="none">Select an Office</option>';
  25.  
  26.  
  27. while ($rd_query->have_posts()) : $rd_query->the_post();
  28.  
  29. // add each div with excerp. It's ID is unique and correlates to value of select drop down
  30. $brand = (get_post_meta($post->ID, 'brand', true));
  31. $model = (get_post_meta($post->ID, 'model', true));
  32. $html_out .= '<option value="office-'.$post->ID.'" class="office-entry" id="office-'.$post->ID.'">'.$model.'</option>';
  33. $select .= '<option value="office-'.$post->ID.'">'.$brand.'</option>';
  34. endwhile;
  35.  
  36. // wrap up $select
  37. $select .= '</select>';
  38. $html_out .= '</select>';
  39.  
  40. echo $select;
  41. echo $html_out;
  42.  
  43.  
  44. ?>
  45.  
  46. <script type="text/javascript">
  47. jQuery(function($){
  48. $('#office-chooser').change(function(){
  49. var $selected_office = $(this).val();
  50. if(($selected_office == 'none') ){
  51. $('div.office-entry').hide();
  52. $('#office-chooser2').hide();
  53. $('#' + $selected_office).hide();
  54. } else {
  55. $('#' + $selected_office).show();
  56. $('#office-chooser2').show();
  57.  
  58. }
  59. });
  60. });
  61. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement