bbp_get_reply_url( int $reply_id, string $redirect_to = '' )
Return the paginated url to the reply in the reply loop
Description
Parameters
- $reply_id
-
(Optional) Reply id
- $redirect_to
-
(Optional) Pass a redirect value for use with shortcodes and other fun things.
Default value: ''
Return
(string) Link to reply relative to paginated topic
Source
File: bp-forums/replies/template.php
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 | function bbp_get_reply_url( $reply_id = 0, $redirect_to = '' ) { // Set needed variables $reply_id = bbp_get_reply_id ( $reply_id ); $topic_id = bbp_get_reply_topic_id( $reply_id ); // Hierarchical reply page if ( bbp_thread_replies() ) { $reply_page = 1; // Standard reply page } else { $reply_page = ceil ( (int) bbp_get_reply_position( $reply_id , $topic_id ) / (int) bbp_get_replies_per_page() ); } $reply_hash = '#post-' . $reply_id ; $topic_link = bbp_get_topic_permalink( $topic_id , $redirect_to ); $topic_url = remove_query_arg( 'view' , $topic_link ); // Don't include pagination if on first page if ( 1 >= $reply_page ) { $url = trailingslashit( $topic_url ) . $reply_hash ; // Include pagination } else { global $wp_rewrite ; // Pretty permalinks if ( $wp_rewrite ->using_permalinks() ) { $url = trailingslashit( $topic_url ) . trailingslashit( $wp_rewrite ->pagination_base ) . trailingslashit( $reply_page ) . $reply_hash ; // Yucky links } else { $url = add_query_arg( 'paged' , $reply_page , $topic_url ) . $reply_hash ; } } // Add topic view query arg back to end if it is set if ( bbp_get_view_all() ) $url = bbp_add_view_all( $url ); return apply_filters( 'bbp_get_reply_url' , $url , $reply_id , $redirect_to ); } |
Changelog
Version | Description |
---|---|
bbPress (r2679) | 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.