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
1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 | 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.