在bbPress主页中编辑<title>

时间:2017-02-13 15:24:54

标签: wordpress bbpress

&lt; p&gt;我想做类似的事情:&lt; code&gt;&lt; title&gt;自定义文字...&lt; / title&gt;&lt; / code&gt; 在bbPress主页上。我花了几个小时寻找答案,我找不到它......&lt; / p&gt; &lt; p&gt;我知道可以创建页面并添加类似的短代码:&lt; a href =“https://codex.bbpress.org/features/shortcodes/"rel =”nofollow noreferrer“&gt; https:/ /codex.bbpress.org/features/shortcodes/</a> 但是在这种情况下,如果bbPress的root slug与页面相同,则它不起作用。如果slug不同 - 我将有两个主页:/&lt; / p&gt; &lt; p&gt;有没有人有类似的问题?&lt; / p&gt;

1 个答案:

答案 0 :(得分:0)

您可以使用此挂钩在bbPress主页顶部执行自定义代码。

'bbp_template_before_forums_index'

示例:

add_action( 'bbp_template_before_forums_index', 'your_callback_function' );
function your_callback_function(){
  $output_html = '';
  $output_html .= "<title>Custom text...</title>";
  echo $output_html;
}

在你的functions.php文件中使用此代码,我希望它能为你提供帮助。