Skip to content

Commit

Permalink
When counting projects, don't count archived (fixes #910)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Abraham <[email protected]>
  • Loading branch information
cjyabraham committed Dec 4, 2024
1 parent e0b9ea7 commit ff24ddf
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion web/wp-content/themes/cncf-twenty-two/classes/class-lf-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit ff24ddf

Please sign in to comment.