Skip to:
Content
Pages
Categories
Search
Top
Bottom

post count – 1

  • @flutedrumr

    Participant

    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.

Viewing 9 replies - 1 through 9 (of 9 total)
  • @ranrar

    Member

    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 ?

    @nolageek

    Participant

    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.

    @ear1grey

    Member

    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);

    ?>

    @flutedrumr

    Participant

    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.

    @nolageek

    Participant

    For some reason my “Latest Discussions” went from 1’s to -1’s instead of 0’s.

    http://overnights.org

    @flutedrumr

    Participant

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

    @nolageek

    Participant

    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);

    ?>

    @flutedrumr

    Participant

    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!

    @ganzua

    Member

    The problem with adding a filter is that you lose the function for counting the total amount of posts.

    How can you convert nolageek code into a new function “topic_replies”? ;

    <?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);
    ?>

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