Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $max_price_query = new WP_query(array(
- 'posts_per_page' => -1,
- 'post_status' => 'publish',
- 'post_type' => 'properties',
- 'nopaging' => true,
- 'orderby' => 'meta_value_num',
- 'meta_key' => '_price',
- 'order' => 'DESC',
- ));
- if ($max_price_query->have_posts()) {
- while ($max_price_query->have_posts()) : $max_price_query->the_post();
- $pid = $post->ID;
- $price_max = get_post_meta($pid, '_price', true);
- echo '<pre>' . $pid . '</pre>';
- endwhile;
- wp_reset_postdata();
- }
- function set_query_parameters($query) {
- if( !is_admin() && is_main_query() && is_post_type_archive( 'properties' ) ) {
- $query->set('meta_key', '_featured_prop');
- return $query;
- }
- add_action( 'pre_get_posts', 'set_query_parameters' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement