Last active
May 15, 2017 15:13
-
-
Save BhargavBhandari90/805fd66a7ccf75fb3823bd1036b6a833 to your computer and use it in GitHub Desktop.
Get randome image in member's loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add this function to theme's functions.php | |
/** | |
* Show randome album image in member's loop. | |
*/ | |
function rtmedia_members_gallery() { | |
global $wpdb; | |
if ( function_exists( 'bp_get_member_user_id' ) ) { | |
// Get member's ID. | |
$member_id = bp_get_member_user_id(); | |
$user_query = "SELECT * FROM `{$wpdb->prefix}rt_rtm_media` WHERE `media_author` = '{$member_id}' AND `media_type` = 'photo' ORDER BY rand() LIMIT 1"; | |
$thumb_detail = $wpdb->get_row( $user_query ); | |
$members_media_image = wp_get_attachment_image( $thumb_detail->media_id, 'thumbnail' ); | |
if ( ! empty( $members_media_image ) ) { | |
echo $members_media_image; | |
} | |
} | |
} | |
add_action( 'bp_directory_members_actions', 'rtmedia_members_gallery' ); | |
?> | |
// Add this to custom css ( rtMedia->settings->Custom CSS ) | |
#buddypress ul.item-list li .item { | |
float: left !important; | |
width: 55% !important; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment