bbp_update_topic_reply_count_hidden( int $topic_id, int $reply_count )
Adjust the total hidden reply count of a topic (hidden includes trashed and spammed replies)
Description
Parameters
- $topic_id
-
(Optional) Topic id to update
- $reply_count
-
(Optional) Set the reply count manually
Return
(int) Topic hidden reply count
Source
File: bp-forums/topics/functions.php
function bbp_update_topic_reply_count_hidden( $topic_id = 0, $reply_count = 0 ) {
global $wpdb;
// If it's a reply, then get the parent (topic id)
if ( bbp_is_reply( $topic_id ) ) {
$topic_id = bbp_get_reply_topic_id( $topic_id );
} else {
$topic_id = bbp_get_topic_id( $topic_id );
}
// Get replies of topic
if ( empty( $reply_count ) ) {
$post_status = "'" . implode( "','", array( bbp_get_trash_status_id(), bbp_get_spam_status_id() ) ) . "'";
$reply_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_parent = %d AND post_status IN ( {$post_status} ) AND post_type = '%s';", $topic_id, bbp_get_reply_post_type() ) );
}
update_post_meta( $topic_id, '_bbp_reply_count_hidden', (int) $reply_count );
return apply_filters( 'bbp_update_topic_reply_count_hidden', (int) $reply_count, $topic_id );
}
Changelog
| Version | Description |
|---|---|
| bbPress (r2740) | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.