Skip to:
Content
Pages
Categories
Search
Top
Bottom

comments_popup_link

  • i’m looking for a way to use the same output like in wp for the comments like:

    <?php comments_popup_link('no comments', 'one comment', ' % comments'); ?> instead of <?php forum_topics(); ?> <?php _e('post(s) or comment(s)'); ?> .

    so is there a php pendant in bbpress to count comments or posts the wordpress way?

    thank’s in advance

Viewing 4 replies - 1 through 4 (of 4 total)

  • Olaf Lederer
    Participant

    @finalwebsites

    Hi,

    I see this template and function in all the WP themes, how does this work in wordpress?

    Knowing this it might be possible fro bbpress too…

    http://phpxref.ftwr.co.uk/wordpress/nav.html?wp-includes/comment-template.php.source.html

    In WordPress, comments_popup_link() takes three arguments that tell it how to format the output based on how many comments are present and runs a sprintf() with the appropriate output after retrieving the comment count.

    The equivalent to get_comments_number in bbPress would be get_topic_posts, the rest of the function is either WordPress-specific or would need slight tweaking (like what the posts page would actually be).

    Something like:

    function posts_number( $id = 0, $zero = false, $one = false, $more = false ) { // Port of WP's comments_number
    $topic = get_topic( get_topic_id( $id ) );
    $number = $topic->topic_posts;

    if ( $number > 1 )
    $output = str_replace('%', bb_number_format_i18n($number), ( false === $more ) ? __('% Posts') : $more);
    elseif ( $number == 0 )
    $output = ( false === $zero ) ? __('No Posts') : $zero;
    else // must be one
    $output = ( false === $one ) ? __('1 Post') : $one;

    echo apply_filters('posts_number', $output, $number);
    }

    should work I think. Misread the original question slightly.

    you guys should be rewarded as the estimated inventory of the bbpress community, kudos :)

    btw, thank’s for the “whole” code and your precision in your replies kawauso, i’ll keep that in mind.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar