我可以在bp_get_activity_content_body()
上使用entry.php
但我如何在bp-core-template.php
抱歉,我的问题很糟糕,我是php编辑的新手。
答案 0 :(得分:0)
bp-core-template.php是BuddyPress的核心文件之一,这使得编辑文件成为一个坏主意。每当您更新Buddypress时,您的更改很可能会被覆盖。
如果您尝试更改bp-core-template.php中找到的函数的结果,那么您将需要使用该函数中的一个过滤器来安全地更改内容“wordpress方式”。
因此,如果您想更改bp-core-template.php第877行上找到的函数bp_create_excerpt的输出,您可以使用主题的functions.php文件中的过滤器bp_create_excerpt。
在functions.php中(从hookr.io修改的示例):
// define the bp_create_excerpt callback
function filter_bp_create_excerpt( $text, $original_text, $length, $options ) {
if ( function_exists( bp_get_activity_content_body )
$text = bp_get_activity_content_body();
return $text;
};
// add the filter
add_filter( 'bp_create_excerpt', 'filter_bp_create_excerpt', 10, 4 );
编辑:应该注意的是,我不知道bp_get_activity_content_body()将在此上下文中返回什么,如果我不想要截断的摘录,我可能只返回$ original_text。我的目的是强调你应该如何从插件的核心文件中改变输出。