bbp_get_reply_id( $reply_id )
Return the id of the reply in a replies loop
Description Description
Parameters Parameters
- $reply_id
-
(Optional) Used to check emptiness
Return Return
(int) The reply id
Source Source
File: includes/replies/template.php
function bbp_get_reply_id( $reply_id = 0 ) {
$bbp = bbpress();
$wp_query = bbp_get_wp_query();
// Easy empty checking
if ( ! empty( $reply_id ) && is_numeric( $reply_id ) ) {
$bbp_reply_id = $reply_id;
// Currently inside a replies loop
} elseif ( ! empty( $bbp->reply_query->in_the_loop ) && isset( $bbp->reply_query->post->ID ) ) {
$bbp_reply_id = $bbp->reply_query->post->ID;
// Currently inside a search loop
} elseif ( ! empty( $bbp->search_query->in_the_loop ) && isset( $bbp->search_query->post->ID ) && bbp_is_reply( $bbp->search_query->post->ID ) ) {
$bbp_reply_id = $bbp->search_query->post->ID;
// Currently viewing a forum
} elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && ! empty( $bbp->current_reply_id ) ) {
$bbp_reply_id = $bbp->current_reply_id;
// Currently viewing a reply
} elseif ( ( bbp_is_single_reply() || bbp_is_reply_edit() ) && isset( $wp_query->post->ID ) ) {
$bbp_reply_id = $wp_query->post->ID;
// Fallback
} else {
$bbp_reply_id = 0;
}
// Filter & return
return (int) apply_filters( 'bbp_get_reply_id', $bbp_reply_id, $reply_id );
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |