bbp_get_reply_position( int $reply_id, int $topic_id )

Return the numeric position of a reply within a topic


Description Description


Parameters Parameters

$reply_id

(Optional) Reply id

$topic_id

(Optional) Topic id


Top ↑

Return Return

(int) Reply position


Top ↑

Source Source

File: includes/replies/template.php

	function bbp_get_reply_position( $reply_id = 0, $topic_id = 0 ) {

		// Get required data
		$reply_id       = bbp_get_reply_id( $reply_id );
		$reply_position = get_post_field( 'menu_order', $reply_id );

		// Reply doesn't have a position so get the raw value
		if ( empty( $reply_position ) ) {

			// 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( 'bbp_get_reply_position', $reply_position, $reply_id, $topic_id );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.