$dynamic_post_types, 'post_status' => [ 'publish', 'pending' ], 'posts_per_page' => -1, // Retrieve all posts 'fields' => 'ids', // Fetch only post IDs to optimize performance ]; $listings_count = count( get_posts( $args ) ); return (int) $listings_count; } else { $args = [ 'post_type' => $dynamic_post_types, 'post_status' => $status, 'posts_per_page' => -1, // Retrieve all posts 'fields' => 'ids', // Fetch only post IDs to optimize performance ]; $listings_count = count( get_posts( $args ) ); if ( $listings_count ) { return (int) $listings_count; } else { return 0; } } } public static function listing_count_by_today( $status = 'publish' ) { $dynamic_post_types = adqs_get_directory_post_types(); $args = [ 'post_type' => $dynamic_post_types, 'post_status' => $status, 'date_query' => [ [ 'year' => current_time( 'Y' ), 'month' => current_time( 'm' ), 'day' => current_time( 'd' ), ], ], 'posts_per_page' => -1, // Retrieve all posts 'fields' => 'ids', // Fetch only post IDs to optimize performance ]; $listings_count = count( get_posts( $args ) ); if ( $listings_count ) { return (int) $listings_count; } else { return 0; } } }