Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply count in widget Latest posts


  • WilRC
    Participant

    @wilrc

    Help!
    I’m trying to get replycounts after the the latest posttitle. (widget)
    e.g:
    Avatar – Name – date – title – (number of replies)
    I can’t get it working. This is sofar I have now:

    $forum_id = bbp_get_topic_forum_id($topic_id); 
    		$topic_id = bbp_get_topic_id($widget_query->post->ID);
    		$reply_id   = bbp_get_reply_id( $widget_query->post->ID );
    
    					$reply_link = '<a class="bbp-reply-topic-title" href="' . esc_url( bbp_get_reply_url( $reply_id ) ) . '" title="' . esc_attr( bbp_get_reply_excerpt( $reply_id, 50 ) ) . '">' . bbp_get_reply_topic_title( $reply_id ) . '</a> ('.bbp_get_topic_post_count($forum_id, $topic_id, $total_count).')<br />'. esc_attr( bbp_get_reply_excerpt( $reply_id, 40 ) ) . '';
    

    This is a snippet form the BBP latest post widget. It counts replies but not for separatly the latest post. It gives wrong results and those countresults are different on what page you’re visting. (index, forum, topicpage ect.)
    Could somebody put me in the wright direction?

    Many thanks in advance.

Viewing 1 replies (of 1 total)

  • WilRC
    Participant

    @wilrc

    Fixed, to everyone who it will be useful:

    / Verify the reply ID
    		$topic_id = bbp_get_topic_id($widget_query->post->ID);
    		$forum_id = bbp_get_reply_topic_id($topic_id); 
    		$reply_id   = bbp_get_reply_id( $widget_query->post->ID );
    		$topic_count       = bbp_get_forum_reply_count( $forum_id, false, true );
    		$total_reply_count = bbp_get_topic_reply_count($forum_id);
    
    					$reply_link = '<a class="bbp-reply-topic-title" href="' . esc_url( bbp_get_reply_url( $reply_id ) ) . '" title="' . esc_attr( bbp_get_reply_excerpt( $reply_id, 50 ) ) . '">' . bbp_get_reply_topic_title( $reply_id ) . '</a> ('.$total_reply_count.')<br />'. esc_attr( bbp_get_reply_excerpt( $reply_id, 40 ) ) . '';
    
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar