Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 21st, 2012  |  syntax: PHP  |  size: 2.04 KB  |  views: 37  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <form name="search" action="" method="get">
  2.   <select name="filter">
  3.   <?php
  4.   $metakey = 'Colour';
  5.   $counties = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = %s ORDER BY meta_value ASC", $metakey) );
  6.   if ($counties) {
  7.     foreach ($counties as $filter) {
  8.       echo "<option value=\"" . $filter . "\">" . $filter . "</option>";
  9.     }
  10.   }
  11.   ?>
  12.   <input type="submit" value="search" />
  13. </form>
  14.  
  15.  
  16. <?php
  17. $counties = $_GET['filter'];
  18. if ($counties) {
  19.   $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  20.  
  21.   $args=array(
  22.     'meta_value' => $counties,
  23.     'paged'=>$paged,
  24.     'offset'=>1,
  25.   );
  26.  
  27.   query_posts($args);
  28. } else {
  29.   query_posts('cat=98&orderby=rand&posts_per_page=10');
  30. }
  31.  
  32. if ($counties) { ?>
  33.   <h3>Your Search For <?php echo $counties; ?></h3>
  34.   <?php } else { ?>
  35.   <h3>Recently Added</h3>
  36.   <?php }
  37.  
  38. if (have_posts()) :  while (have_posts()) : the_post();
  39.  
  40. $event_filter = get_post_meta($post->ID, 'filter', true);
  41.  
  42.   $imagefeed = get_post_meta($post->ID, 'Image',  true);
  43.   $minprice = get_post_meta($post->ID, 'Minimum Price',  true);
  44.   $brand = get_post_meta($post->ID, 'Brand',  true);
  45.   $oldprice = get_post_meta($post->ID, 'Old Price',  true);
  46.   $permalink = get_permalink( $id );
  47.   echo '<div class="inbox">';
  48.   echo '<a href="'.$permalink.'">';
  49.   echo "<img src='".$imagefeed."' return alt='".get_the_title()."'/>";
  50.   echo '</a>';
  51.   echo '<br>';
  52.   echo '</a>';
  53.   echo '<div class="textbox">';
  54.   echo 'Merk: ' . $brand;
  55.   echo '<br>';
  56.   echo '<div class="homepageprijs"><span>' . '€ ' . $minprice . '</span></div>';
  57.     if($oldprice != $minprice && intval($oldprice) > 0.00)
  58.                 echo '<span> € ' . $oldprice . '</span>' . '<br>';
  59.         else
  60.                 echo '';
  61.   echo '</div>';
  62.   echo '</div>';
  63. endwhile;
  64.  
  65. ?>
  66. </div><!-- einde postarea -->
  67.   <?php echo $event_filter; ?>
  68.  
  69. </div><!-- einde contentleftoverview -->
  70. <?php else : ?>
  71. <p>Sorry no results were found</p>
  72. <?php endif; ?>
  73.  
  74. <?php wp_reset_query(); ?>