bbp_get_non_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'


Top ↑

Return Return

(int) The number of children


Top ↑

Source Source

File: includes/common/functions.php

function bbp_get_non_public_child_count( $parent_id = 0, $post_type = 'post' ) {

	// Bail if nothing passed
	if ( empty( $parent_id ) || empty( $post_type ) ) {
		return false;
	}

	// Which statuses
	switch ( $post_type ) {

		// Forum
		case bbp_get_forum_post_type() :
			$post_status = bbp_get_non_public_forum_statuses();
			break;

		// Topic
		case bbp_get_topic_post_type() :
			$post_status = bbp_get_non_public_topic_statuses();
			break;

		// Reply
		case bbp_get_reply_post_type() :
			$post_status = bbp_get_non_public_reply_statuses();
			break;

		// Any
		default :
			$post_status = bbp_get_public_status_id();
			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_non_public_child_count', $child_count, $parent_id, $post_type );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 bbPress (r5954) Replace direct queries with WP_Query() objects
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.