bbp_get_public_child_count( int $parent_id, string $post_type = 'post' )
Query the DB and get a count of public children
Description Description
Parameters Parameters
- $parent_id
-
(Required) Parent id.
- $post_type
-
(Optional) Post type. Defaults to 'post'.
Default value: 'post'
Return Return
(int) The number of children
Source Source
File: includes/common/functions.php
function bbp_get_public_child_count( $parent_id = 0, $post_type = 'post' ) { // Bail if nothing passed if ( empty( $post_type ) ) { return false; } // Which statuses switch ( $post_type ) { // Forum case bbp_get_forum_post_type() : $post_status = bbp_get_public_forum_statuses(); break; // Topic case bbp_get_topic_post_type() : $post_status = bbp_get_public_topic_statuses(); break; // Reply case bbp_get_reply_post_type() : default : $post_status = bbp_get_public_reply_statuses(); break; } // Get counts $counts = bbp_filter_child_counts_list( $parent_id, $post_type, $post_status ); $child_count = isset( $counts[ $post_type ] ) ? bbp_number_not_negative( array_sum( array_values( $counts[ $post_type ] ) ) ) : 0; // Filter & return return (int) apply_filters( 'bbp_get_public_child_count', $child_count, $parent_id, $post_type ); }
Changelog Changelog
Version | Description |
---|---|
2.6.0 | bbPress (r5954) Replace direct queries with WP_Query() objects |
2.0.0 | Introduced. |