我正在使用 buddypress 主题 [buddyboss] ( http://buddyboss.com/ )。主要原因是这个主题能够管理图片库(效果很好)。
我现在想在成员循环中调用该图片功能。其中一位 buddyboss-admins 告诉我:
“您将需要 buddy_boss_pics.php 中的函数。具体而言,您需要使用函数 buddyboss_pics_screen_picture_grid_content() 从第 285 行开始。您需要编辑文件以使用成员循环,因为它当前使用 display_user_id。”
这是函数的外观:
function buddyboss_pics_screen_picture_grid_content()
{
global $bp, $wpdb, $bbpics;
$wpdb->show_errors = BUDDY_BOSS_DEBUG;
$img_size = is_active_sidebar( 'Profile' ) ? 'buddyboss_pic_med' : 'buddyboss_pic_wide';
$gallery_class = is_active_sidebar( 'Profile' ) ? 'gallery has-sidebar' : 'gallery';
$user_id = $bp->displayed_user->id;
$activity_table = $wpdb->prefix."bp_activity";
$activity_meta_table = $wpdb->prefix."bp_activity_meta";
$pages_sql = "SELECT COUNT(*) FROM $activity_table a INNER JOIN $activity_meta_table am ON a.id = am.activity_id WHERE a.user_id = $user_id AND meta_key = 'bboss_pics_aid'";
$bbpics->grid_num_pics = $wpdb->get_var($pages_sql);
$bbpics->grid_current_page = isset( $_GET['page'] ) ? (int) $_GET['page'] : 1;
// Prepare a SQL query to retrieve the activity posts
// that have pictures associated with them
$sql = "SELECT a.*, am.meta_value FROM $activity_table a INNER JOIN $activity_meta_table am ON a.id = am.activity_id WHERE a.user_id = $user_id AND meta_key = 'bboss_pics_aid' ORDER BY a.date_recorded DESC";
buddy_boss_log("SQL: $sql");
$pics = $wpdb->get_results($sql,ARRAY_A);
$bbpics->grid_pagination = new BuddyBoss_Paginated( $pics, $bbpics->grid_pics_per_page, $bbpics->grid_current_page );
buddy_boss_log("RESULT: $pics");
// If we have results let's print out a simple grid
if ( !empty( $pics ) )
{
$bbpics->grid_had_pics = true;
$bbpics->grid_num_pics = count( $pics );
任何帮助都会很棒,因为我真的需要这样做!