public static function getProperties($type = 'newest', $order = 'default', $count = 10) { $args = array('post_type' => 'properties', 'post_status' => 'publish', 'posts_per_page' => $count); if ($order == 'default') { $args['orderby'] = 'post_date'; $args['order'] = 'DESC'; } else { if ($order == 'random') { $args['orderby'] = 'rand'; } } // Prevent multiple instances of the same post if WPML is installed $args['suppress_filters'] = false; $meta_query = array(); if ($type == 'featured') { $meta_query[] = array('key' => USE_PREFIX . 'featured', 'value' => 'on'); } $args['meta_query'] = $meta_query; $key = md5(serialize($args)); $_properties = wp_cache_get($key, THEME_NAME); if (!$_properties) { $properties = get_posts($args); $_properties = array(); foreach ($properties as $property) { $p = new Property(); $p->setData($property); $_properties[] = $p; } wp_cache_set($key, $_properties, THEME_NAME); } self::$last_query_found_items_count = count($_properties); return $_properties; }