Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Pagination after deleting posts

@wilc097

Participant

I have been looking at the function more closely, and think the correct code is as follows:

add_filter ('bbp_get_reply_position' , 'rew_redo_reply_position') ;

function rew_redo_reply_position ($reply_id=0, $topic_id=0) {
	// Get required data
	$reply_id       = bbp_get_reply_id( $reply_id );

			// Get topic ID
			$topic_id = ! empty( $topic_id )
					? bbp_get_topic_id( $topic_id )
					: bbp_get_reply_topic_id( $reply_id );

			// Post is not the topic
			if ( $reply_id !== $topic_id ) {
					$reply_position = bbp_get_reply_position_raw( $reply_id, $topic_id );

					// Update the reply position in the posts table so we'll never have
					// to hit the DB again.
					if ( ! empty( $reply_position ) ) {
							bbp_update_reply_position( $reply_id, $reply_position );
					}

			// Topic's position is always 0
			} else {
					$reply_position = 0;
			}

	// Bump the position by one if the topic is included in the reply loop
	if ( ! bbp_show_lead_topic() ) {
			$reply_position++;
	}

	// Filter & return
	return (int) apply_filters( 'rew_redo_reply_position', $reply_id, $topic_id );
}
Skip to toolbar