rtmedia_get_media_comment_count

Get media comment count using media ID.

Description

(int) rtmedia_get_media_comment_count( (bool) $media_id = false ); 

Returns (int)

Parameters (1)

0. $media_id — Optional. (bool) => false
The media id.

Usage

  1. if ( !function_exists( 'rtmedia_get_media_comment_count' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'rtmedia-for-wordpress-buddypress-and-bbpress/app/main/controllers/template/rtmedia-functions.php'; 
  3.  
  4. // The media id. 
  5. $media_id = false; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = rtmedia_get_media_comment_count($media_id); 
  9.  

Defined (1)

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

/app/main/controllers/template/rtmedia-functions.php  
  1. function rtmedia_get_media_comment_count( $media_id = false ) { 
  2.  
  3. global $wpdb, $rtmedia_media; 
  4.  
  5. if ( ! $media_id ) { 
  6. $post_id = $rtmedia_media->media_id; 
  7. } else { 
  8. $post_id = rtmedia_media_id( $media_id ); 
  9.  
  10. $query = $wpdb->prepare( "SELECT count(*) FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ); 
  11. $comment_count = $wpdb->get_results( $query, ARRAY_N ); // @codingStandardsIgnoreLine 
  12.  
  13. if ( is_array( $comment_count ) && is_array( $comment_count[0] ) && isset( $comment_count[0][0] ) ) { 
  14. return $comment_count[0][0]; 
  15. } else { 
  16. return 0; 
  17.