Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: How to add latest reply or topic to forum list

@pinkishhue

Participant

Ok got it, needs sprucing up design-wise but this nicely outputs the reply content and date (with permalink) directly under the topic title on the single forum view topics list:

(With thanks to some code used here – https://bbpress.org/forums/topic/how-to-get-reply-ids-within-topic-loop/)

// https://bbpress.org/forums/topic/how-to-add-latest-reply-or-topic-to-forum-list/ - SHOW REPLIES ON SINGLE FORUM LIST OF TOPICS
function jagreplies_add_last_reply() { { 
$new_args = array(
    'post_type'=> 'reply'
);
$topic_id = bbp_get_topic_id();
$new_args['post_parent'] = $topic_id;

$new_query = new WP_Query( $new_args );

if ( $new_query->have_posts() ) : while ( $new_query->have_posts() ) : $new_query->the_post();

     $reply_id=$post->ID;
     $reply_title= get_the_title();
     $reply_date= get_the_date();
     $reply_content= the_content(); 
     $reply_permalink= get_the_permalink(); 
	?>

     <div class="the_content">
		<?php echo $reply_content; ?>
		<a href="<?php echo $reply_permalink ?>"><?php echo $reply_date ?></a>
	</div>
                     
   <?php endwhile; ?>   
   <?php endif; 

    }} 
// Hook into action
add_action('bbp_theme_after_topic_freshness_author','jagreplies_add_last_reply');
Skip to toolbar