Info
- 10 posts
- 5 voices
- Started 5 years ago by flutedrumr
- Latest reply from ganzua
- This topic is not a support question
post count - 1
-
- Posted 5 years ago #
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 5 years ago #
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 5 years ago #
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 5 years ago #
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 5 years ago #
Thanks mate; that worked awesome! I added a second function so the forum count was corrected also:
I also had to change line 699 in template-functions.php to:
<?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);
?>If anyone has a suggestion for doing this in the plugin instead of modifying the core, let me know.
-
- Posted 5 years ago #
For some reason my "Latest Discussions" went from 1's to -1's instead of 0's.
-
- Posted 5 years ago #
That happened on one of mine; when I reset the counts (Admin->Site Management) it fixed it.
-
- Posted 5 years ago #
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 5 years ago #
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 3 years ago #
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); ?> -
You must log in to post.