Advertisement
Guest User

Untitled

a guest
May 6th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. $max_price_query = new WP_query(array(
  2. 'posts_per_page' => -1,
  3. 'post_status' => 'publish',
  4. 'post_type' => 'properties',
  5. 'nopaging' => true,
  6. 'orderby' => 'meta_value_num',
  7. 'meta_key' => '_price',
  8. 'order' => 'DESC',
  9. ));
  10.  
  11. if ($max_price_query->have_posts()) {
  12. while ($max_price_query->have_posts()) : $max_price_query->the_post();
  13. $pid = $post->ID;
  14. $price_max = get_post_meta($pid, '_price', true);
  15. echo '<pre>' . $pid . '</pre>';
  16. endwhile;
  17. wp_reset_postdata();
  18. }
  19.  
  20. function set_query_parameters($query) {
  21. if( !is_admin() && is_main_query() && is_post_type_archive( 'properties' ) ) {
  22. $query->set('meta_key', '_featured_prop');
  23. return $query;
  24. }
  25. add_action( 'pre_get_posts', 'set_query_parameters' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement