bbp_get_forum_last_reply_url

Return the url to the last reply in a forum.

Description

(string) bbp_get_forum_last_reply_url( (int) $forum_id = 0 ); 

Returns (string)

Paginated URL to latest reply

Parameters (1)

0. $forum_id — Optional. (int)
Forum id

Usage

  1. if ( !function_exists( 'bbp_get_forum_last_reply_url' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/forums/template.php'; 
  3.  
  4. // Optional. Forum id 
  5. $forum_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_get_forum_last_reply_url($forum_id); 
  9.  

Defined (1)

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

/includes/forums/template.php  
  1. function bbp_get_forum_last_reply_url( $forum_id = 0 ) { 
  2. $forum_id = bbp_get_forum_id( $forum_id ); 
  3.  
  4. // If forum has replies, get the last reply and use its url 
  5. $reply_id = bbp_get_forum_last_reply_id( $forum_id ); 
  6. if ( !empty( $reply_id ) ) { 
  7. $reply_url = bbp_get_reply_url( $reply_id ); 
  8.  
  9. // No replies, so look for topics and use last permalink 
  10. } else { 
  11. $reply_url = bbp_get_forum_last_topic_permalink( $forum_id ); 
  12.  
  13. // No topics either, so set $reply_url as empty string 
  14. if ( empty( $reply_url ) ) { 
  15. $reply_url = ''; 
  16.  
  17. // Filter and return 
  18. return apply_filters( 'bbp_get_forum_last_reply_url', $reply_url, $forum_id );