Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply count for topics issue – bbp_topic_reply_count


  • J_Mo
    Participant

    @j_mo

    Hi there,

    I am currently working on my first bbPress site and thoroughly enjoying it! I have one issue though…

    On my home page I have a list of 8 latest posts on the site. They include news (standard WP posts), events (custom post type) and bbPress topics and are displayed with query_posts().

    I am trying to display the reply count of topics but can’t using bbp_topic_reply_count(), it simply returns 0.

    <?php if ( 'topic' == get_post_type()  ) : ?>
    	<article class="bit-4 newsPost grid-sizer grid-item">
        	<div class="eventInner homePost">
            	<p class="postLabel">Discussion</p>
                	<h1 class="eventListTitle"><a href="<?php the_permalink(); ?> "><?php the_title(); ?></a></h1>
                    	<p class="postedOn"><?php bbp_topic_reply_count(); ?> comments, starting on<?php the_date('d M Y'); ?></p>
                        	<p><?php echo get_excerpt(); ?></p>
            	</div>
        </article>
    <?php endif; ?>

    Am I missing something? Can someone help please?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • You are out of your forum environment, so you need to give the post ID as a parameter to the bbp_topic_reply_count

    Pascal.


    J_Mo
    Participant

    @j_mo

    Thanks

    Is there a show_topic_ID() or something?


    J_Mo
    Participant

    @j_mo

    Solved it! I had to get the ID of the ‘topic’ custom post type and pass it to bbp_topic_reply_count

    <?php if ( 'topic' == get_post_type()  ) : ?>
    
    				<?php $topic = get_the_ID(); ?>
                        		<article class="bit-4 newsPost grid-sizer grid-item">
                                	<div class="eventInner homePost">
                                        <p class="postLabel">Discussion</p>
                        				<h1 class="eventListTitle"><a href="<?php the_permalink(); ?> "><?php the_title(); ?></a></h1>
                                        <p class="postedOn"><?php the_date('d M Y'); ?>, <?php bbp_topic_reply_count(  $topic_id = $topic ); ?></p>
                                		<p><?php echo get_excerpt(); ?></p>
                                    </div>
                            	</article>
    						<?php endif; ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar