bbp_get_reply_url

Return the paginated url to the reply in the reply loop.

Description

(string) bbp_get_reply_url( (int) $reply_id = 0, (string) $redirect_to = '' ); 

Returns (string)

Link to reply relative to paginated topic

Parameters (2)

0. $reply_id — Optional. (int)
Reply id
1. $redirect_to — Optional. (string) => ''
Pass a redirect value for use with shortcodes and other fun things.

Usage

  1. if ( !function_exists( 'bbp_get_reply_url' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/replies/template.php'; 
  3.  
  4. // Optional. Reply id 
  5. $reply_id = -1; 
  6.  
  7. // Optional. Pass a redirect value for use with 
  8. // shortcodes and other fun things. 
  9. $redirect_to = ''; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = bbp_get_reply_url($reply_id, $redirect_to); 
  13.  

Defined (1)

The function is defined in the following location(s).

/includes/replies/template.php  
  1. function bbp_get_reply_url( $reply_id = 0, $redirect_to = '' ) { 
  2.  
  3. // Set needed variables 
  4. $reply_id = bbp_get_reply_id ( $reply_id ); 
  5. $topic_id = bbp_get_reply_topic_id( $reply_id ); 
  6.  
  7. // Hierarchical reply page 
  8. if ( bbp_thread_replies() ) { 
  9. $reply_page = 1; 
  10.  
  11. // Standard reply page 
  12. } else { 
  13. $reply_page = ceil( (int) bbp_get_reply_position( $reply_id, $topic_id ) / (int) bbp_get_replies_per_page() ); 
  14.  
  15. $reply_hash = '#post-' . $reply_id; 
  16. $topic_link = bbp_get_topic_permalink( $topic_id, $redirect_to ); 
  17. $topic_url = remove_query_arg( 'view', $topic_link ); 
  18.  
  19. // Don't include pagination if on first page 
  20. if ( 1 >= $reply_page ) { 
  21. $url = trailingslashit( $topic_url ) . $reply_hash; 
  22.  
  23. // Include pagination 
  24. } else { 
  25. global $wp_rewrite; 
  26.  
  27. // Pretty permalinks 
  28. if ( $wp_rewrite->using_permalinks() ) { 
  29. $url = trailingslashit( $topic_url ) . trailingslashit( $wp_rewrite->pagination_base ) . trailingslashit( $reply_page ) . $reply_hash; 
  30.  
  31. // Yucky links 
  32. } else { 
  33. $url = add_query_arg( 'paged', $reply_page, $topic_url ) . $reply_hash; 
  34.  
  35. // Add topic view query arg back to end if it is set 
  36. if ( bbp_get_view_all() ) 
  37. $url = bbp_add_view_all( $url ); 
  38.  
  39. return apply_filters( 'bbp_get_reply_url', $url, $reply_id, $redirect_to );