我正在使用buddypress主题[buddyboss](http://buddyboss.com/)。主要原因是这个主题能够管理图片库(效果很好)。
我现在想在members-loop中调用该picture-function。其中一位buddyboss-admins告诉我:
“你将需要buddy_boss_pics.php中的函数。具体来说,你需要使用函数buddyboss_pics_screen_picture_grid_content()从第285行开始。你需要编辑文件以使用members-loop,因为它目前使用的是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 );
任何帮助都会很棒,因为我真的需要这样做!
答案 0 :(得分:0)
未经测试 - 但试试这个:
在members-loop中,查找
<?php
/***
* If you want to show specific profile fields here you can,
* but it'll add an extra query for each member in the loop
* (only one regadless of the number of fields you show):
*
* bp_member_profile_data( 'field=the field name' );
*/
?>
在关闭php标记之前添加这个?&gt;
buddyboss_pics_members_loop( bp_get_member_user_id() );
将buddyboss_pics_screen_picture_grid_content()函数复制到members-loop的底部。
将它放在php标签之间并将名称更改为 buddyboss_pics_members_loop($ user_id)
并注释或删除 $ user_id = $ bp-&gt; displayed_user-&gt; id;
答案 1 :(得分:0)
这里buddyboss_pics_screen_picture_grid_content()函数主要使用user_id并从数据库中获取图像。
很简单,你在member-loop.php文件中的while循环中调用了这个函数:
buddyboss_pics_screen_picture_grid_content(bp_member_user_id())
这里传递此函数的参数member_user_id。
很少编辑下面的主要buddyboss_pics_screen_picture_grid_content()
功能:
以下更改:
function buddyboss_pics_screen_picture_grid_content($user_id = null)
{
//Remove this code
$user_id = $bp->displayed_user->id;
//Put new Code
if (empty($user_id)) {
$user_id = $bp->displayed_user->id;
} else {
$user_id = $user_id;
}
}