bbp_update_reply_position( type $reply_id, type $reply_position )

Update the position of the reply.

Description

The reply position is stored in the menu_order column of the posts table. This is done to prevent using a meta_query to retrieve posts in the proper freshness order. By updating the menu_order accordingly, we’re able to leverage core WordPress query ordering much more effectively.

Parameters

$reply_id

(type) (Required)

$reply_position

(type) (Required)

Return

(mixed)

Source

File: bp-forums/replies/functions.php

function bbp_update_reply_position( $reply_id = 0, $reply_position = 0 ) {

	// Bail if reply_id is empty
	$reply_id = bbp_get_reply_id( $reply_id );
	if ( empty( $reply_id ) )
		return false;

	// If no position was passed, get it from the db and update the menu_order
	if ( empty( $reply_position ) ) {
		$reply_position = bbp_get_reply_position_raw( $reply_id, bbp_get_reply_topic_id( $reply_id ) );
	}

	// Update the replies' 'menp_order' with the reply position
	wp_update_post( array(
		'ID'         => $reply_id,
		'menu_order' => $reply_position
	) );

	return (int) $reply_position;
}

Changelog

Changelog
Version Description
bbPress (r3933) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.