From ff24ddf15dc0655fd4243855d140f1110d0d71ee Mon Sep 17 00:00:00 2001 From: Chris Abraham Date: Wed, 4 Dec 2024 15:27:19 -0800 Subject: [PATCH] When counting projects, don't count archived (fixes #910) Signed-off-by: Chris Abraham --- .../classes/class-lf-utils.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/web/wp-content/themes/cncf-twenty-two/classes/class-lf-utils.php b/web/wp-content/themes/cncf-twenty-two/classes/class-lf-utils.php index 8f32b263..0658b8ed 100644 --- a/web/wp-content/themes/cncf-twenty-two/classes/class-lf-utils.php +++ b/web/wp-content/themes/cncf-twenty-two/classes/class-lf-utils.php @@ -463,7 +463,24 @@ public static function get_homepage_metrics() { $metrics['contributors'] = $remote_body->contributors; $metrics['contributions'] = $remote_body->contributions; $metrics['countries'] = $remote_body->countries; - $metrics['projects'] = wp_count_posts( 'lf_project' )->publish; + + $args = array( + 'post_type' => 'lf_project', + 'posts_per_page' => -1, + 'tax_query' => array( + array( + 'taxonomy' => 'lf-project-stage', + 'field' => 'slug', + 'terms' => array( 'graduated', 'incubating', 'sandbox' ), + 'operator' => 'IN', + ), + ), + 'fields' => 'ids', // Only retrieve post IDs to minimize memory usage. + ); + + $query = new WP_Query( $args ); + $metrics['projects'] = $query->found_posts; + wp_reset_postdata(); if ( WP_DEBUG === false ) { set_transient( 'cncf_homepage_metrics', $metrics, DAY_IN_SECONDS );