bbPress

Simple, Fast, Elegant

bbPress support forums » Plugins

post count - 1

(9 posts)
  • Started 2 years ago by flutedrumr
  • Latest reply from flutedrumr
  • This topic is not a support question

No tags yet.

  1. flutedrumr
    Member

    Not sure if this would be the correct forum for this, but...

    What would be the easiest way to decrease the post counters by one? So it only lists the number of responses, not including the original post.

    Posted 2 years ago #
  2. The same happent to me when i deletet alle post in the first forum bbpress automatic made when installing, I think its becors you not made the first topic yourself it count -1 ?

    Posted 2 years ago #
  3. nolageek
    Member

    No, I see what he means. Saying "1 post" is redundant.. if there wasn't one post in that topic, the topic wouldn't exist. :) It should say "REPLIES" and list the number of posts in the topic, minus 1 (the original post.)

    How we do that, I have no idea.. I'm still trying to find a list of template tags and attributes.

    Posted 2 years ago #
  4. Try this... copy bb-template/front-page.php to my-templates/front-page.php and then in that file find:
    <th><?php _e('Posts'); ?></th>

    then change 'Posts' to 'Replies'. Now, in your my-plugins folder create a file called decrement-posts.php and put this in it:

    <?php
    function bb_decrement( $value ) {
    return $value-1;
    }
    add_filter( 'get_topic_posts', 'bb_decrement', 1);
    ?>

    Posted 2 years ago #
  5. flutedrumr
    Member

    Thanks mate; that worked awesome! I added a second function so the forum count was corrected also:

    <?php
    function bb_decrement_topic( $value ) {
    return $value-1;
    }
    function bb_decrement_forum( $value ) {
    global $forum;
    return $value-get_forum_topics();
    }
    add_filter( 'get_topic_posts', 'bb_decrement_topic', 1);
    add_filter( 'get_forum_posts', 'bb_decrement_forum', 1);
    ?>

    I also had to change line 699 in template-functions.php to:
    $posts = sprintf('%1$s %2$s', $post_num, __ngettext( 'reply', 'replies', $post_num ));

    If anyone has a suggestion for doing this in the plugin instead of modifying the core, let me know.

    Posted 2 years ago #
  6. nolageek
    Member

    For some reason my "Latest Discussions" went from 1's to -1's instead of 0's.

    http://overnights.org

    Posted 2 years ago #
  7. flutedrumr
    Member

    That happened on one of mine; when I reset the counts (Admin->Site Management) it fixed it.

    Posted 2 years ago #
  8. nolageek
    Member

    I couldn't get rid of the -1's, so I tinkered with it until it was working for me. This is working .73 as well.

    <?php
    function bb_decrement( $value ) {
    return $value-1;
    }
    add_filter( 'get_topic_posts', 'bb_decrement', 1);
    ?>
    <?php
    function bb_decrement_topic( $value ) {
    global $forum;
    return $value;
    }
    function bb_decrement_forum( $value ) {
    global $forum;
    return $value-get_forum_topics();
    }
    add_filter( 'get_topic_posts', 'bb_decrement_topic', 1);
    add_filter( 'get_forum_posts', 'bb_decrement_forum', 1);
    ?>

    Posted 2 years ago #
  9. flutedrumr
    Member

    Whoops, I should have specified that the code I posted replaced ear1grey's. If you keep both then there are two filters being added to your "get_topic_posts", which would cause the -1's you've been seeing. Sorry 'bout that!

    Posted 2 years ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.