bbp_get_reply_position( int $reply_id, int $topic_id )
Return the numeric position of a reply within a topic
Description
Parameters
- $reply_id
-
(Optional) Reply id
- $topic_id
-
(Optional) Topic id
Return
(int) Reply position
Source
File: bp-forums/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 ) ) { $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 lead topic is in the replies loop if ( ! bbp_show_lead_topic() ) $reply_position++; return (int) apply_filters( 'bbp_get_reply_position', $reply_position, $reply_id, $topic_id ); }
Changelog
Version | Description |
---|---|
bbPress (r2984) | 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.