Advertisement
bastetmilo

Comparing by meta_value

Jun 6th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.06 KB | None | 0 0
  1.         $citySize =  array(
  2.                     'key' => '_bm_min_city',
  3.                     'value' => array(50000,100000),
  4.                     'compare' => 'BETWEEN',
  5.                     'type' => 'numeric'
  6.                         );
  7.         $investemntRange = array(
  8.                     'key' => '_bm_start_costs',
  9.                     'value' => 10000,
  10.                     'compare' => '<',
  11.                     'type' => 'numeric'
  12.                         );
  13.  
  14. function bm_release_the_frannies($citySize, $investemntRange){
  15.     global $post;
  16.     $args = array(
  17.                 'post_type' => 'cpt_franchize',
  18.                 'meta_query' => array(
  19.                     $citySize,
  20.                     $investemntRange
  21.                     )
  22.                  );
  23.  
  24.  
  25.  
  26.     $results = new WP_Query($args);
  27.  
  28.     if ( $results->have_posts() ) : while ( $results->have_posts() ) : $results->the_post();
  29.  
  30.     $bm_cost_licens = get_post_meta($post->ID, '_bm_cost_licens', true);
  31.     $bm_cost_venue = get_post_meta($post->ID, '_bm_cost_venue', true);
  32.     $bm_cost_merchandise = get_post_meta($post->ID, '_bm_cost_merchandise', true);
  33.     $bm_start_costs =  get_post_meta($post->ID, '_bm_start_costs', true);
  34.     $bm_return_invest = get_post_meta($post->ID, '_bm_return_invest', true);
  35.  
  36.     ?>
  37.     <article>
  38.         <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  39.         <p>Koszty startowy: <strong><?php echo $bm_start_costs; ?></strong></p>
  40.         <ul>
  41.             <li><?php if (! empty( $bm_cost_licens ) ) {echo $bm_cost_licens;} else { echo 'b.d.'; } ?></li>
  42.             <li><?php if (! empty( $bm_cost_venue ) ) {echo $bm_cost_venue;} else { echo 'b.d.'; } ?></li>
  43.             <li><?php if (! empty( $bm_cost_merchandise ) ) {echo $bm_cost_merchandise;} else { echo 'b.d.'; } ?></li>
  44.         </ul>
  45.         <p>Szacowany zwrot z inwestycji: <?php if (! empty( $bm_return_invest ) ) {echo $bm_return_invest;} else { echo 'b.d.'; } ?></p>
  46.     </article>
  47.     <?php
  48.  
  49.     endwhile;
  50.  
  51.     else:
  52.  
  53.         echo 'Brak rezultatów w podanym zakresie';
  54.  
  55.     endif;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement