ID, 'topic' );
$d_users[$forumuser->ID] = $post_count;
}
arsort( $d_users );
$i = 0;
foreach ( $d_users as $key => $value ) {
$i++;
$user = get_userdata( $key );
$parent_id = get_queried_object_id();
//$users_post_count = count_user_posts( $user->ID, 'topic' );
$users_post_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '" . $user->ID . "' AND post_type = 'topic' AND post_status = 'publish' AND post_parent = '" . $parent_id . "' " );
$author_posts_url = get_author_posts_url( $key );
$post_count = $users_post_count;
if ( $post_count > 0 ) {
echo '
';
}
}
}
}
/**
* Tag Name
*
* @return string
*/
public static function forum_topics_tags() {
$args = [
'post_type' => 'topic',
'post_parent' => get_queried_object_id(),
'post_status' => 'publish',
'order' => 'ASC',
'orderby' => 'ID',
'posts_per_page' => -1,
];
$forumaxtags = new WP_Query( $args );
if ( $forumaxtags->have_posts() ):
$i=1;
while ( $forumaxtags->have_posts() ): $forumaxtags->the_post();
global $post;
$get_tags = get_the_terms( get_the_ID(), 'topic-tag' );
if ( $get_tags ) {
foreach ( $get_tags as $tag ) {
$post_count = $tag->count;
echo '';
}
}
$i++;
endwhile;
endif;
}
/**
* Tag Name
*
* @return void
*/
public static function forum_topics_open_close(): void
{
$is_queried_obj = is_singular('forum') ? get_queried_object_id() : false;
$user_id = is_singular('forum') ? false : bbp_get_displayed_user_field('ID');
// Get the active tab from the URL or default to 'open'
$active_tab = isset($_GET['tab']) && in_array($_GET['tab'], ['open', 'closed']) ? sanitize_text_field($_GET['tab']) : 'open';
// Query for Open Topics Count
$open_args = [
'post_type' => 'topic',
'post_parent' => $is_queried_obj,
'post_status' => 'publish',
'posts_per_page' => -1, // No pagination for count
];
$open_query = new WP_Query($open_args);
$open_count = $open_query->found_posts;
// Query for Closed Topics Count
$closed_args = [
'post_type' => 'topic',
'post_parent' => $is_queried_obj,
'post_status' => 'closed',
'posts_per_page' => -1,
];
$closed_query = new WP_Query($closed_args);
$closed_count = $closed_query->found_posts;
if ( in_array('bbp-user-page', get_body_class()) ) :
?>