简体   繁体   English

WP-BuddyPress(search_terms)搜索问题

[英]WP - BuddyPress (search_terms) searching Issue

I am trying to create a script that will search members from profile values. 我正在尝试创建一个脚本,该脚本将从配置文件值中搜索成员。 I have no problem doing this with one field however, when I try to add more search terms the code displays only the last term added in the code. 我在一个字段中执行此操作没有问题,但是当我尝试添加更多搜索词时,代码仅显示代码中添加的最后一个词。 Please see the code: 请查看代码:

<?php if (( bp_has_members( "search_terms={$_POST['category']}")) && ( bp_has_members( "search_terms={$_POST['area_members']}"))) : ?>
<?php while ( bp_members() ) : bp_the_member(); ?>

....

<?php endwhile; ?>
<?php endif; ?> 

When I do this the result its just a search of the last term ['area_members'], the term ['category'] its not initiated. 当我这样做时,结果只是对最后一个词['area_members']的搜索,而对词['category']的搜索却没有启动。

Any Idea why and how I can achieve this? 任何想法为什么以及如何实现这一目标?

The second call ( or last call ) to bp_has_members is the one used in the while loop. bp_has_members的第二次调用(或最后一次调用)是while循环中使用的那个。 To search on multiple terms, put a space between each term. 要搜索多个词,请在每个词之间放置一个空格。 The search is based on 'AND', not 'OR'. 搜索基于“与”而不是“或”。

Try: 尝试:

$search_terms = $_POST['category'] . ' ' . $_POST['area_members'];
if ( bp_has_members( "search_terms={$search_terms}")) :

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM