wordpress - 在 buddypress 站点的任何位置添加 "Add Friend Button"

标签 wordpress buddypress

我试图在成员(member)页面外放置一个“添加 friend ”按钮,在一个循环内,这样该按钮就会出现在帖子中作者头像的旁边。 我尝试添加 ;

<?php if ( bp_is_active( 'friends' ) ) { ?>

                        <?php bp_add_friend_button( $user_ids['users'][$i]->id ) ?>

                    <?php } ?>

在循环内部,但没有返回任何结果。 然后我在 functions.php 中放置了以下操作 Hook ,它在循环内显示了按钮,但是一旦单击,帖子列表中的所有按钮也都被单击了。

 add_action( ‘the_content’, ‘bp_add_friend_button’, 5 );

所以现在我卡住了。我想,在模板中添加一个模板标签会起作用,因为它适用于“发送消息”按钮。

最佳答案

尝试

<?php if ( function_exists( 'bp_add_friend_button' ) ) : ?> <?php bp_add_friend_button() ?> <?php endif; ?>

关于wordpress - 在 buddypress 站点的任何位置添加 "Add Friend Button",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14491524/

相关文章:

php - acf,从字段获取缩略图大小的图像

css - 仅将图像调整到一定大小

javascript - 如何在wordpress模板中定义jquery

php - 在 Woocommerce 订单页面中,创建与订单 ID 相关的自定义文本字段

javascript - 未捕获的类型错误 : Cannot call method 'getElementsByTagName' of null

wordpress - 如何在发布循环中显示Buddypress个人资料字段的内容

css - 如何更改 BuddyBoss 主题中链接的 CSS

mysql - 如何在 MySQL 中使用数组