bp_get_group_forum_post_count

Generate the post count string for a group forum.

Description

(string|int) bp_get_group_forum_post_count( (string) $args = '' ); 

Returns (string|int)

Parameters (1)

0. $args — Optional. (string) => ''
Array of arguments.

Options

    ;        


    Usage

    1. if ( !function_exists( 'bp_get_group_forum_post_count' ) ) { 
    2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-groups/bp-groups-template.php'; 
    3.  
    4. // Array of arguments. 
    5. $args = ''; 
    6.  
    7. // NOTICE! Understand what this does before running. 
    8. $result = bp_get_group_forum_post_count($args); 
    9.  

    Defined (1)

    The function is defined in the following location(s).

    /bp-groups/bp-groups-template.php  
    1. function bp_get_group_forum_post_count( $args = '' ) { 
    2. global $groups_template; 
    3.  
    4. $defaults = array( 
    5. 'showtext' => false 
    6. ); 
    7.  
    8. $r = wp_parse_args( $args, $defaults ); 
    9. extract( $r, EXTR_SKIP ); 
    10.  
    11. if ( !$forum_id = groups_get_groupmeta( $groups_template->group->id, 'forum_id' ) ) { 
    12. return false; 
    13.  
    14. if ( !bp_is_active( 'forums' ) ) { 
    15. return false; 
    16.  
    17. if ( !$groups_template->group->forum_counts ) { 
    18. $groups_template->group->forum_counts = bp_forums_get_forum_topicpost_count( (int) $forum_id ); 
    19.  
    20. if ( (bool) $showtext ) { 
    21. if ( 1 == (int) $groups_template->group->forum_counts[0]->posts ) { 
    22. $total_posts = sprintf( __( '%d post', buddypress ), (int) $groups_template->group->forum_counts[0]->posts ); 
    23. } else { 
    24. $total_posts = sprintf( __( '%d posts', buddypress ), (int) $groups_template->group->forum_counts[0]->posts ); 
    25. } else { 
    26. $total_posts = (int) $groups_template->group->forum_counts[0]->posts; 
    27.  
    28. /** 
    29. * Filters the post count string for a group forum. 
    30. * @since 1.2.0 
    31. * @param string $total_posts Total post count string. 
    32. * @param bool $showtext Whether or not to return as formatted string. 
    33. */ 
    34. return apply_filters( 'bp_get_group_forum_post_count', $total_posts, (bool)$showtext );