prepare(" SELECT post_author, COUNT(*) as post_count FROM $wpdb->posts WHERE post_type = %s AND post_status = 'publish' GROUP BY post_author ORDER BY post_count DESC LIMIT %d, %d ", $post_type, $offset, $per_page); $author_posts = $wpdb->get_results($query); wp_cache_set($cache_key, $author_posts, 'adqs_cache'); } // Caching the total author count query $total_authors_cache_key = "adqs_all_agents_total"; $total_authors = wp_cache_get($total_authors_cache_key, 'adqs_cache'); if ($total_authors === false) { $total_authors = $wpdb->get_var($wpdb->prepare(" SELECT COUNT(DISTINCT post_author) FROM $wpdb->posts WHERE post_type = %s AND post_status = 'publish' ", $post_type)); // Set the cache with a timeout of 1 hour (3600 seconds) wp_cache_set($total_authors_cache_key, $total_authors, 'adqs_cache'); } if (!empty($author_posts)) : do_action('adqs_before_main_content'); ?>