当在简码中包含member / members-loop.php模板并用我自己的查询替换查询时,它返回正确的信息,但是将per_page
设置为较低的值后,它不会创建分页并且查询vars显示用户总数与每个页面选项相同。
我加入了bp_user_query_uid_clauses
过滤器和bp_pre_user_query
动作来更改查询,该结果提供了大约4个结果,但是如果设置了&per_page
,那么只有两个没有分页显示。 / p>
add_filter( 'bp_user_query_uid_clauses', 'replace_query', 10, 1 );
function replace_query( $_array ) {
$_array[ 'select' ] = ... the query ...
$_array[ 'orderby' ] = 'ORDER BY user';
$_array[ 'where' ] = '';
$_array[ 'order' ] = 'ASC';
return $_array;
}
查询:
SELECT SQL_CALC_FOUND_ROWS
USER
FROM
(
SELECT
user_id AS USER
FROM
wp_bp_xprofile_data
WHERE
field_id = 5 AND DATE( VALUE ) > '1972-7-15' AND
DATE( VALUE ) <= '1998-7-15' AND user_id <> 1
UNION ALL
SELECT
user_id AS USER
FROM
wp_bp_xprofile_data
WHERE
field_id = 26 AND( VALUE = 'Red' )
AND user_id <> 1
) AS users
GROUP BY
USER
HAVING
COUNT(*) >= 3
自定义页面简码:
include bp_get_theme_compat_dir( ) . 'buddypress/members/members-loop.php';
也许buddypress count_total
发现行在查询中无法正常工作?
编辑:指定?upage = 2有效,但是用户总数仍为2,并且未创建分页。