bbPress 樣式參考

bbPress 樣式參考

本指南將向您展示新 bbPress 論壇的區域,您可以使用 CSS 以及 bbPress 插件中使用的類和選擇器來設置每個區域的樣式。

設計您的論壇

這些可以添加到您的 css 中,或添加到 bbpress.css 的自定義版本中 – 請參閲設置 bbpress 論壇的分步指南第 2 部分瞭解更多信息。

論壇嬰兒牀

論壇

bbPress 論壇中的所有內容

這是用於 bbPress 論壇所有部分的 CSS 。根據您的需要增加字體大小。

#bbpress-forums { background: transparent; clear: both; margin-bottom: 20px; overflow: hidden; font-size: 12px; }

1. 論壇頁眉和頁腳

這是顯示作者、帖子和聲音等標籤的內容。

#bbpress-forums li.bbp-header, #bbpress-forums li.bbp-footer {  background: #f3f3f3;  border-top: 1px solid #eee;  font-weight: bold;  padding: 8px;  text-align: center; }   #bbpress-forums li.bbp-header {  background: #eaeaea; }

2. 回覆標題

#bbpress-forums div.bbp-reply-header {     background-color: #f4f4f4; }

3. 模板通知信息

div.bbp-template-notice.info {     border: #cee1ef 1px solid;     background-color: #f0f8ff; }

4. 話題/回覆背景

賠率,即使如此回覆也有交替的顏色

#bbpress-forums div.even, #bbpress-forums ul.even {  background-color: #fff; }   #bbpress-forums div.odd, #bbpress-forums ul.odd {  background-color: #fbfbfb; }

如果話題很粘或超級粘,那麼

.bbp-topics-front ul.super-sticky, .bbp-topics ul.super-sticky, .bbp-topics ul.sticky, .bbp-forum-content ul.sticky {  background-color: #ffffe0 !important;  font-size: 1.1em; }

自定義關閉話題文本的顏色。

#bbpress-forums .status-closed, #bbpress-forums .status-closed a {  color: #ccc; }

每個線程的線程回覆邊距。

#bbpress-forums ul.bbp-threaded-replies {  margin-left: 50px; }

5. 各種文字

這些通常繼承自您的主題。

但是,您可以使用修改內容

#bbpress-forums .bbp-topic-content, #bbpress-forums .bbp-reply-content {     font-size: 12px; }

上面的代碼不在 bbpress.css 中,因此如果需要,請添加它,或放入您的 .css 中,請參閲頂部提到的指南以獲取更多信息

6. 管理鏈接

span.bbp-admin-links {  float: right;  color: #ddd; }   span.bbp-admin-links a {  color: #bbb;  font-weight: normal;  font-size: 10px;  text-transform: uppercase;  text-decoration: none; }

7. 模板通知

div.bbp-template-notice, div.indicator-hint {  border-width: 1px;  border-style: solid;  padding: 0 0.6em;  margin: 5px 0 15px;  border-radius: 3px;  background-color: #ffffe0;  border-color: #e6db55;  color: #000;  clear: both; } div.bbp-template-notice a {  color: #555;  text-decoration: none; }  div.bbp-template-notice a:hover {  color: #000;  }  div.bbp-template-notice.info {  border: #cee1ef 1px solid;  background-color: #f0f8ff;  }  div.bbp-template-notice.important {  border: #e6db55 1px solid;  background-color: #fffbcc;  }  div.bbp-template-notice.error,  div.bbp-template-notice.warning {  background-color: #ffebe8;  border-color: #c00;  }  div.bbp-template-notice.error a,  div.bbp-template-notice.warning a {  color: #c00;  }  div.bbp-template-notice p {  margin: 0.5em 0 6px 0 !important;  padding: 2px;  font-size: 12px;  line-height: 140%;  }

8. 從您的主題繼承的麪包屑和鏈接顏色

9. 其他造型功能

9.1 提交按鈕

正在尋找一種方法來更改 bbpress 、更大、顏色中的提交按鈕......?

#bbpress-forums .submit {     background-color: #a0668d;     color: #FFFFFF;     float: center;     vertical-align: middle;     border-radius: 10px;     height: 35px;     width: 80px;     font-size: 18px; }

並更改為您想要的!

10. 從最近的話題小工具和新鮮度中刪除頭像

widget_display_topics .bbp-author-avatar {     display: none ! important; }   .bbp-topic-freshness-author  .bbp-author-avatar {     display: none ! important; }

bbp_topic_author_link

bbp_topic_author_link

bbp_topic_author_link
Codex Home → bbp_topic_author_link
Description
The 『bbp_topic_author_link』 function is used to display the current topic author』s user role, avatar and username linked to their profile
Where is it used
Templates: content-single-topic-lead.php
How to use it

$args (optional) – Accepts an array of arguments to configure display ( post_id, link_title, type, size, sep, show_role )
Uses bbp_get_topic_author_link()
Sample code example

Displays the linked avatar and username for the current topic author
'
', 'show_role' => true ) ); ?>
Displays the current topic author and user role separated by an HTML
element
'
', 'show_role' => true, 'size' => 32 ) ); ?>
Displays the current topic author and user role separated by an HTML
element and sets their avatar to a size of 32px wide and 32px tall
'
', 'show_role' => false, 'type' => 'avatar' ) ); ?>
Displays only the current topic author user』s avatar without their display name or user role
'
', 'show_role' => false, 'type' => 'name' ) ); ?>
Displays only the current topic author user』s display name without their avatar or user role
Related
bbp_author_link()
bbp_reply_author_link()
bbp_show_lead_topic()

佈局和功能 - 您可以使用的示例

佈局和功能 - 您可以使用的示例

您可以使用 WordPress 和 bbPress 提供的鈎子和過濾器以多種方式自定義和擴展 WordPress 和 bbPress,還可以將一些 CSS 應用到您的論壇或主題。

下面是一些常用的自定義 PHP 和 CSS 代碼片段列表,這些代碼片段可能對社區用户自定義他們現有的 bbPress 論壇有用。

如果您發現列出的示例似乎不起作用,您想建議另一個有用的示例,或者使用不同/更好的方法來編輯當前的最終功能,然後請進入支持論壇並在論壇請求和反饋

1. 更改論壇列表的顯示方式

默認看起來像: 論壇2

改成 : 論壇3

默認情況下,此元素使用 CSS 設置樣式。

#bbpress-forums .bbp-forums-list li { display: inline; }

將此 CSS 代碼片段粘貼到您的子主題的 style.css 並更改 display:inline 為 display:block 將實現此佈局。

您也可以改用 PHP 代碼片段,並將以下函數放入您的子主題 functions.php 文件中。

//create vertical list subforum layout function custom_bbp_sub_forum_list() {   $args['separator'] = ' ';   return $args; }  add_filter('bbp_after_list_forums_parse_args', 'custom_bbp_sub_forum_list' );

2. 從論壇列表中刪除話題/回覆計數

默認 :

論壇c
更改為:
論壇b
您可以更改 loop.single.forum.php,如 https://codex.bbpress.org/step-by-step-guide-to-setting-up-a-bbpress-forum-part-3/ 所示或者

將以下內容放入您的子主題 functions.php 文件中。

function remove_counts() {     $args['show_topic_count'] = false;     $args['show_reply_count'] = false;     $args['count_sep'] = ''; return $args; } add_filter('bbp_before_list_forums_parse_args', 'remove_counts' );

3. 向登錄小工具添加 「修改個人資料/密碼」

雖然您可以單擊 bbPress 登錄小工具中顯示的頭像或您的用户名轉到您的個人資料,然後從那裏單擊編輯鏈接來編輯您的個人資料,但這對您的某些用户來説可能並不那麼明顯。

安裝這個插件 RKK Login Widget,它幾乎與默認的 bbPress Login Widget 完全相同。只需將 (RKK) 登錄小工具放置到側邊欄之一,您的登錄小工具就會與此類似。

論壇

根據需要自定義或編輯插件。

4. 關閉或更改麪包屑

要刪除論壇中的麪包屑,請確保將此功能添加到子主題或功能插件中的 functions.php 文件中。

add_filter( 'bbp_no_breadcrumb', '__return_true' );

要自定義您要顯示的特定麪包屑鏈接的佈局,請將其添加到您的子主題 function.php 文件中。

function mycustom_breadcrumb_options() {     // Home - default = true     $args['include_home']    = false;     // Forum root - default = true     $args['include_root']    = false;     // Current - default = true     $args['include_current'] = true;       return $args; } add_filter('bbp_before_get_breadcrumb_parse_args', 'mycustom_breadcrumb_options');

5. 移除論壇搜索功能

如果您想刪除搜索欄 (有些人喜歡要麼排除它,要麼把它放在側邊欄中)

默認情況下,搜索表單將顯示如下。
論壇

這是之後的結果。
論壇

然後只需更改儀表盤> 設置> 論壇功能中的設置並取消勾選
Allow forumwide search 。

6. bbpress 後加載樣式表

介紹:當 WordPress 加載樣式表時,它們會先加載所有 theme.css 文件,然後再加載插件 css 。這樣插件 css 的優先級高於您的 css,唯一可以覆蓋它的方法是使用 !important 。眾所周知,這是一種不好的做法。

此外,您可以在您的主題中創建自己的 bbpress.css ,但這意味着需要處理更多文件 (儘管這是最乾淨的解決方案) 。這是執行此操作的另一種方法:

將此代碼粘貼到您的子主題 functions.php 文件中。

/** * load custom bbpress css after bbp default css */ wp_enqueue_style( 'custom-bbpress', get_stylesheet_directory_uri() . '/css/custom-bbpress.css',array('bbp-default'),'1.1','all');

7. 如何從模板中刪除所有面包屑並將它們設置在頁面頂部?

由 Markic 提交併感謝

簡介:我們中的許多人正在使用標題中的現有面包屑系統創建自己的主題。但是 bbPress 有自己的想法在哪裏顯示麪包屑,有時在頁面頂部,有時在搜索表單下方,有時在標題下方。這是您可以快速更改的方法。

1. 如果還沒有,請在主題的根文件夾中創建 「bbpress.php」 。
2. 添加

<div class="truebreadcrumbs"><?php bbp_breadcrumb(); ?></div>

3. 添加此 CSS:

div.bbp-breadcrumb {  display: none; /*this will hide all breadcrumbs*/  }   .truebreadcrumbs div.bbp-breadcrumb {  display: block; /*this will display breadcrumbs you've created*/  }

當然,HTML 仍然會生成所有的麪包屑,而 css 會隱藏不需要的麪包屑,但這是最簡單的方法,無需進入模板。

8. 將 「編輯個人資料」 添加到 wordpress 菜單

大多數 bbPress 用户都有側邊欄,並使用小工具來控制登錄和個人資料更改。其他人則依賴於用户知道如果點擊他們的頭像或用户名,那麼他們就可以編輯他們的個人資料。

此解決方案允許您將 「編輯個人資料」 添加到您的 wordpress 菜單中——這僅在用户登錄時顯示為菜單項。

將以下內容添加到您的函數文件中

// Filter wp_nav_menu() to add profile link add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link' ); function my_nav_menu_profile_link($menu) {     if (!is_user_logged_in())         return $menu;     else         $current_user = wp_get_current_user();         $user=$current_user->user_nicename ;         $profilelink = '<li><a href="/forums/users/' . $user . '/edit">Edit Profile</a></li>';         $menu = $menu . $profilelink;         return $menu;   }

9. 將社交媒體聯繫人添加到 bbPress 個人資料

感謝 nicmare 提供這個方便的提示。

您可以通過將這些添加到 contactmethods 來添加和刪除社交媒體聯繫人。

以下示例函數添加了 twitter 、 facebook 、 google+ 和 youtube,但刪除了
目標、 yabber 和 yim 。

function add_extra_contactmethod( $contactmethods ) { // Add new ones $contactmethods['twitter'] = 'Twitter'; $contactmethods['facebook'] = 'Facebook'; $contactmethods['googleplus'] = 'Google Plus'; $contactmethods['youtube'] = 'Youtube';   // remove unwanted unset($contactmethods['aim']); unset($contactmethods['jabber']); unset($contactmethods['yim']);   return $contactmethods; } add_filter('user_contactmethods', 'add_extra_contactmethod');

10. 縮短新鮮度的措辭

此代碼縮短新鮮度取出分鐘

只需將其放入您的函數文件中

//function to shorten freshness display from say '1 month, 2 weeks' to '1 month' function short_freshness_time( $output) { $output = preg_replace( '/, .*[^ago]/', ' ', $output ); return $output; } add_filter( 'bbp_get_time_since', 'short_freshness_time' ); add_filter('bp_core_time_since', 'short_freshness_time');

11. 簡單地在菜單中添加登錄/註銷

為用户添加用於登錄/註銷、註冊或恢復其密碼的菜單項到您的站點菜單非常有用,尤其是在您決定不使用 bbPress 側邊欄登錄小工具的情況下。

將以下 php 代碼片段粘貼到您的子主題的 functions.php 文件中。

add_filter( 'wp_nav_menu_items', 'rkk_add_auth_links', 10 , 2 ); function rkk_add_auth_links( $items, $args ) {  if ( is_user_logged_in() ) {  $items .= '<li><a href="'. wp_logout_url() .'">Log Out</a></li>';  }  elseif ( !is_user_logged_in() ) {  $items .= '<li><a href="'. site_url('wp-login.php') .'">Log In</a></li>';  $items .= '<li><a href="'. site_url('wp-login.php?action=register') .'">Register</a></li>';  $items .= '<li><a href="'. site_url('wp-login.php?action=lostpassword') .'">Lost Password</a></li>';  }  return $items; }

您可以根據自己的喜好自定義此功能。如果您想將某些 url 鏈接到自定義前端表單而不是默認的 WordPress 登錄表單,您可以進行這樣的簡單更改,例如。

site_url('wp-login.php') 對此 site_url('/login/')

如果您想在註銷後重定向到自定義 url 。

wp_logout_url() 把這個改成這個 wp_logout_url( site_url('/logout/') )

或者,如果您想在特定菜單中顯示這些菜單項,請在 之後的函數中編輯兩個條件 is_user_logged_in() 。

像這樣添加到現有的條件中,is_user_logged_in() && $args->theme_location == 'primary-menu'.

上面的代碼將在您的功能條件中顯示特定菜單中的菜單項,其中主題位置通常是菜單段。要查找此功能的菜單的 slug/主題位置搜索,通常位於主題 functions.php 文件中 register_nav_menu() 。有關了解 register_nav_menu() 函數的更多信息,請參閲 WordPress 指南導航菜單

12. 添加模態 (彈出) 登錄

這非常好,説明將其添加到菜單中,並根據需要使用登錄/註銷。

登錄看起來像這樣

模態登錄3

有不同的風格可供選擇,您可以設計自己的風格。

説明可以在這裏找到

13. 防止關閉的話題變灰

默認情況下,關閉回覆的話題是 「灰色的」 。但通常您只是想停止發帖,最常見的是針對論壇頂部的熱門話題。

將此代碼添加到主題中的 css 或修改主題 css 文件夾中的 bbpress.css 。

#bbpress-forums .status-closed, #bbpress-forums .status-closed a {   color: #aaa !important; }

14. 添加新的 bbpress 角色

您可以添加新的 bbpress 角色,甚至更改其功能。

在最簡單的級別上,您可以添加新角色名稱併為其賦予現有能力

這僅對您自己的管理目的很有用,但如果像我一樣討厭 「keymaster」 角色名稱,只需創建一個新角色併為其賦予 keymaster 功能。

以下代碼創建了三個名為 「name 1」 、 「name 2」 和 「name 3」 的新角色,第一個角色有參與者、第二個主持人和第三個關鍵管理員。

只需修改代碼即可創建具有您需要的任何功能的任意數量的角色

function add_custom_role( $bbp_roles ) {   $bbp_roles['my_custom_role1'] = array( 'name' => 'name 1', 'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() ) // the same capabilities as participants ); $bbp_roles['my_custom_role2'] = array( 'name' => 'name 2', 'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() ) // the same capabilities as participants ); $bbp_roles['my_custom_role3'] = array( 'name' => 'name 3', 'capabilities' => bbp_get_caps_for_role( bbp_get_keymaster_role() ) // the same capabilities as keymaster ); return $bbp_roles; } add_filter( 'bbp_get_dynamic_roles', 'add_custom_role', 1 );

15. 在 bbpress 角色中添加自定義功能

添加自定義功能

16. 論壇頁面添加説明

如果您創建一個帶有描述的論壇,這隻會顯示在主索引頁面上,而不顯示在類別頁面或論壇頁面上

從:

説明1

到 :

説明2

將以下內容添加到您的函數文件中。

//filter to add description after forums titles on forum index function rw_singleforum_description() {   echo '<div class="bbp-forum-content">';   echo bbp_forum_content();   echo '</div>'; } add_action( 'bbp_template_before_single_forum' , 'rw_singleforum_description');

我還添加了這個自定義 CSS 。將此添加到您的子主題的 style.css 文件中,以將其放置在麪包屑下。

#bbpress-forums div.bbp-forum-content {   clear: both !important;   margin-left: 0 !important;   padding: 0  !important; }

17. 將訂閲移至右側

改變
訂閲1

到:

訂閲2

將以下內容放入您的 style.css

/*styling to move 'Subscribe' to right hand side */ .single-forum .subscription-toggle  {     float:right !important ; }

如果您只想將其稍微向右移動,則可以使用此自定義 CSS 。根據您的喜好調整 5px 。

/*styling to move 'Subscribe' to right hand side */ .single-forum .subscription-toggle  {     padding-left: 5px !important ; }

18. 防止用户更改他們的顯示名稱

用户可以在 bbpress 個人資料頁面中更改他們的顯示名稱。一些論壇希望阻止這種情況以阻止用户隱藏他們的身份。

要關閉此功能,您需要編輯默認文件之一併將其保存到您的主題中。

在您的主題中創建一個 bbpress 文件夾。

wp-content/themes/%yourtheme%/bbpress

其中 %yourtheme% 是您的主題名稱

然後導航到

wp-content/plugins/bbpress/templates/default/bbpress/form-user-edit.php

並將此文件複製到您在上面創建的 bbpress 文件夾中

bbpress 現在將使用這個而不是默認值。

編輯這個新文件並取出第 33 到 45 行

即取出以下內容

<div>             <label for="nickname"><?php _e( 'Nickname', 'bbpress' ); ?></label>             <input type="text" name="nickname" id="nickname" value="<?php bbp_displayed_user_field( 'nickname', 'edit' ); ?>" class="regular-text" tabindex="<?php bbp_tab_index(); ?>" />         </div>         <div>             <label for="display_name"><?php _e( 'Display Name', 'bbpress' ) ?></label>             <?php bbp_edit_user_display_name(); ?>         </div>         <?php do_action( 'bbp_user_edit_after_name' ); ?>

這將刪除設置暱稱和更改顯示名稱的功能。

19. 鏈接到一個隨機的單個話題

這是一個非常漂亮的功能,允許用户通過單擊鏈接瀏覽隨機話題。

如果您啓用了它,它會掛在主要主題之前,否則它還會創建一個名為 [ntwb-bbpress-random-single-topic] 的簡碼,允許您將其放入小工具或 WordPress 帖子中。

// bbPress - Random Single Topic function ntwb_bbpress_random_single_topic() {     if ( bbp_has_topics( array( 'orderby' => 'rand', 'posts_per_page' => 1 ) ) ) {           while ( bbp_topics() ) : bbp_the_topic();               ?>             <a class="bbp-topic-permalink" href="<?php bbp_topic_permalink(); ?>">Random Topic</a>             <?php           endwhile;     } } // Hook into action add_action('bbp_template_before_lead_topic','ntwb_bbpress_random_single_topic'); // Add it as a shortcode [ntwb-bbpress-random-single-topic] add_shortcode('ntwb-bbpress-random-single-topic', 'ntwb_bbpress_random_single_topic');

20. 重命名用户角色名稱

此功能允許您重命名 bbPress 預定義的用户角色。

只需將 「我的自定義 *** 角色名稱」 更改為您喜歡的內容即可。

add_filter( 'bbp_get_dynamic_roles', 'ntwb_bbpress_custom_role_names' );   function ntwb_bbpress_custom_role_names() {     return array(           // Keymaster         bbp_get_keymaster_role() => array(             'name'         => 'My Custom Keymaster Role Name',             'capabilities' => bbp_get_caps_for_role( bbp_get_keymaster_role() )         ),           // Moderator         bbp_get_moderator_role() => array(             'name'         => 'My Custom Moderator Role Name',             'capabilities' => bbp_get_caps_for_role( bbp_get_moderator_role() )         ),           // Participant         bbp_get_participant_role() => array(             'name'         => 'My Custom Participant Role Name',             'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() )         ),           // Spectator         bbp_get_spectator_role() => array(             'name'         => 'My Custom Spectator Role Name',             'capabilities' => bbp_get_caps_for_role( bbp_get_spectator_role() )         ),           // Blocked         bbp_get_blocked_role() => array(             'name'         => 'My Custom Blocked Role Name',             'capabilities' => bbp_get_caps_for_role( bbp_get_blocked_role() )         )     ); }

21. 在論壇索引後顯示 5 個最近的話題

此功能在您的論壇索引後顯示最新的 5 個話題。

// Add Recent Topics to BBPress function recent_bbpress_topics() { { ?>  <?php  if ( bbp_has_topics( array( 'author' => 0, 'show_stickies' => false, 'order' => 'DESC', 'post_parent' => 'any', 'posts_per_page' => 5 ) ) )  bbp_get_template_part( 'bbpress/loop', 'topics' );  ?> <?php }} // Hook into action add_action('bbp_template_after_forums_index','recent_bbpress_topics');

22. 僅顯示 1 個修訂日誌話題和回覆

使用此功能清理您的修訂日誌。

// Only return one entry for revision log otherwise it gets cluttered function bbp_trim_revision_log( $r='' ) {  $arr = array( end( $r ));  reset( $r );    return( $arr ); }   add_filter( 'bbp_get_reply_revisions', 'bbp_trim_revision_log', 20, 1 ); add_filter( 'bbp_get_topic_revisions', 'bbp_trim_revision_log', 20, 1 );

23. 顯示 bbPress 論壇搜索無處不在

在單個論壇和單個話題上方顯示論壇搜索,但不在 bbPress 個人資料上。

//display bbPress search form above sinle topics and forums function rk_bbp_search_form(){       if ( bbp_allow_search()) {         ?>         <div class="bbp-search-form">               <?php bbp_get_template_part( 'form', 'search' ); ?>           </div>         <?php     } }   add_action( 'bbp_template_before_single_forum', 'rk_bbp_search_form' ); add_action( 'bbp_template_before_single_topic', 'rk_bbp_search_form' );

24. 顯示 bbPress 主題的狀態標籤

這些功能中的每一個都將幫助您根據當前主題的狀態添加特定的標籤或圖標。

在每個話題旁邊顯示粘性標籤。

function rk_sticky_topics() {      if ( bbp_is_topic_sticky() && !bbp_is_topic_closed() )       echo '<span class="sticky">[Sticky]</span>'; }   add_action( 'bbp_theme_before_topic_title', 'rk_sticky_topics' );

在每個話題旁邊顯示封閉標籤。

function rk_closed_topics() {      if ( bbp_is_topic_closed() && !bbp_is_topic_sticky() )       echo '<span class="closed">[Closed]</span>'; }   add_action( 'bbp_theme_before_topic_title', 'rk_closed_topics' );

如果該話題的回覆超過 25 條,則顯示熱標籤。
(您可以將 25 更改為任何您想要的)

function rk_hot_topics() {    $reply_count = bbp_get_topic_reply_count();      if ( $reply_count > 25 )       echo '<span class="hot">[Hot]</span>'; }   add_action( 'bbp_theme_before_topic_title', 'rk_hot_topics' );

如果某個話題已關閉且有粘性,則顯示 「公告」 標籤。

function rk_announcement_topics() {      if ( bbp_is_topic_sticky() && bbp_is_topic_closed() )       echo '<span class="announcement">[Announcement]</span>'; }   add_action( 'bbp_theme_before_topic_title', 'rk_announcement_topics' );

創建話題後一小時內顯示 「新」 標籤。
將偏移量更改為您想要的任何值,但請確保數量以秒為單位。
例如 60*60*1 = 3600 seconds ,這是 1 小時的秒數。

function rk_new_topics() { $offset = 60*60*1;      if ( get_post_time() > date('U') - $offset )       echo '<span class="new">[New]</span>'; }   add_action( 'bbp_theme_before_topic_title', 'rk_new_topics' );

您可以通過在圖標字體 HTML 中添加以顯示圖標來輸入圖標。

無論您在哪裏看到這個

echo '<span class="example">[Example]</span>';

您可以輕鬆地將其更改為此。
在這裏,我使用了 Dashicons 圖標字體集中的隨機字體。

echo '<span class="example"><span class="dashicons dashicons-admin-post"></span>[Example]</span>';

如果您要使用基本的 HTML 插入圖標的方式,您可以使用這個小 CSS 片段來設置它們的樣式。

#bbpress-forums li.bbp-topic-title span.dashicons {   float: left;   margin-right: 5px; }

您也可以僅使用 CSS 在話題標題之前或之後插入自定義圖標字體。

這是來自該站點的 Dashicons 示例。

此 CSS 代碼在置頂帖之前的話題圖標之前顯示置頂圖標。

ul.sticky 和 ​​ul.super-sticky 都是該話題的帖子類,您可以利用和自定義更多帖子類。

#bbpress-forums ul.sticky li.bbp-topic-title a.bbp-topic-permalink:before, #bbpress-forums ul.super-sticky li.bbp-topic-title a.bbp-topic-permalink:before {   font: normal 16px/1 'dashicons';   content: '\f450';   margin-right: 5px;   float: left;   padding-top: 3px;   color: #bb0; }

25. 限制用户訪問 WordPress 後端

添加此 PHP 代碼片段以僅允許只能編輯帖子的用户訪問 WordPress 後端。

/**  * Redirect back to homepage and not allow access to  * WP backend for Subscribers.  */ function rkk_redirect_admin(){     if ( ! current_user_can( 'edit_posts' ) ){         wp_redirect( site_url() );         exit;     } } add_action( 'admin_init', 'rkk_redirect_admin' );

您可能還想為參與者禁用 WordPress 工具欄。

/**  * Disable toolbar on the frontend of your website  * for subscribers.  */ function rkk_disable_admin_bar() {     if( ! current_user_can('edit_posts') )         add_filter('show_admin_bar', '__return_false'); } add_action( 'after_setup_theme', 'rkk_disable_admin_bar' );

您也可以安裝 WP Admin No Show 來執行此類操作。

26. 創建一個 bbPress 特定的側邊欄

沒有插件

註冊您的新側邊欄

將此添加到您的子主題 functions.php 文件中

function rkk_widgets_init() {       register_sidebar( array(         'name' => __( 'bbPress Sidebar', 'rkk' ),         'id' => 'bbp-sidebar',         'description' => __( 'A sidebar that only appears on bbPress pages', 'rkk' ),         'before_widget' => '<aside id="%1$s" class="widget %2$s">',         'after_widget' => '</aside>',         'before_title' => '<h3 class="widget-title">',         'after_title' => '</h3>',     ) );     }   add_action( 'widgets_init', 'rkk_widgets_init' );

現在在您的子主題中編輯您的 sidebar.php 文件,並選擇僅在 bbPress 頁面上用 bbPress 側邊欄替換的側邊欄。

此示例使用的是直接來自話題 25 的代碼。我們使用條件 is_bbPress 在 bbPress 頁面上顯示我們想要的側邊欄,並使用!is_bbpress 在 bbPress 頁面上不顯示我們想要替換的側邊欄。

<?php if ( is_active_sidebar( 'sidebar-1' ) && !is_bbpress() ) : ?>           <div id="widget-area" class="widget-area" role="complementary">         <?php dynamic_sidebar( 'sidebar-1' ); ?>         </div><!-- .widget-area -->   <?php elseif ( is_active_sidebar( 'bbp-sidebar' ) && is_bbpress() ) : ?>       <div id="secondary" class="widget-area" role="complementary">     <?php dynamic_sidebar( 'bbp-sidebar' ); ?>     </div><!-- .widget-area -->   <?php endif; ?>

現在轉到儀表盤> 外觀> 小工具,現在您將看到一個名為 「bbPress Sidebar」 的新側邊欄。

添加 bbPress 小工具後,它應該看起來像這樣。

論壇1

帶插件

使用以下任何插件都可以獲得特定於 bbPress 的側邊欄。如果您認為您發現的內容不夠好,我相信還有更多插件可以執行此類功能。

限制小工具

小工具邏輯

bbPress WP 調整

27. 登錄後自定義重定向

要更改用户登錄後重定向到的頁面,有像 Peter's Login Redirect 這樣的 WordPress 插件可以處理重定向,或者您可以使用和自定義此 php 代碼片段來實現相同的功能。

下面的 PHP 代碼片段會將具有 Admin 用户角色的用户重定向到 WordPress 後端,並將其他任何人重定向到您網站的首頁。

/** * WordPress function for redirecting users on login based on user role */ function my_login_redirect( $url, $request, $user ){ if( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) { if( $user->has_cap( 'administrator' ) ) { $url = admin_url(); } else { $url = home_url(); } } return $url; } add_filter('login_redirect', 'my_login_redirect', 10, 3 );

SimplePress

SimplePress

SimplePress
Codex Home → Getting Started → Importing Data → Import Forums → SimplePress
Simple Press v5.x Importer for bbPress
FAQ & Known Issues
Versions
Latest tested version: v5.5.2 – Build 12017
Forums

Forum 『Categories』 are imported as a 『Forum』 – You must manually configure the forum types for 『category』 forum type after the import and recounts have finished.
『Locked Forums』 will be imported as like a normal open forum, again you can close/lock these via the forums panel in wp-admin and setting the forum attributes status to closed.

Topics & Replies

Sticky topics 『topic status』 are not set during import, manually 『stick』 any topics after import and recounts are complete. (See trac ticket #2126)
Custom BBCodes are not supported eg. [youtube] – You will have to manually change these yourself after importing into bbPress using phpMyAdmin.
Smilies are rendered as images if contained in 『code』 tags eg. :)
You may find extra page breaks
and paragraph

elements in topics and replies and is less than ideal and is from the way the BBCodes are converted during the forum import conversion. You will find these primarily around 『blockquotes』 and 『lists』
If you are using bbPress 『Show Lead Topic』 some of the formatting will be broken, it has been converted correctly and is an issue with the content-single-topic-lead.php template, see trac # (Ticket to follow).
elements seem to be a hit and miss at the moment, they render sometimes and sometimes not depending on the import. (not very helpful I know, still digging around this issue)
are not currently enabled to be embedded inline in bbPress by default with topics and replies, everything was converted correctly and we just need to throw some switches and push some buttons before the next release of bbPress to make it work, watch this space.
Topic Tags are not imported as this is a paid extension of SimplePress
File attachments are left as is in the WordPress media library, any posts with attachments the URL』s will have to be manually updated after import.

Users

If you are going to use the same WordPress install for your import you do not need to import the users as they are already in the WordPress wp_users table. If you are setting up a fresh install of WordPress simple check the 『convert users』 option before you start your import.
Any custom SimplePress Moderators or Groups are not converted, any users you wish to make 『moderators』 or 『keymasters』 you will have to assign these roles manually via the main WordPress Admin User panel (/wp-admin/users.php).
User 『Favourites』, 『Subscribed Topics』 or 『Personal Messages (PM』s) are not supported or imported.

References
Notes
Redirecting from your old forum to your new
https://bbpress.org/forums/topic/v2-simple-press-importer-and-first-thoughts/page/2/#post-124953 by @shrewdies

開始修改主要 bbPress 模板

開始修改主要 bbPress 模板

此頁面的目標受眾是基本熟悉編輯 WordPress 主題模板的人。

如果您只是選擇 bbPress 並且想要對正在呈現的模板進行一些基本更改,例如刪除 WordPress 評論代碼或任何僅應在博客文章中顯示的帖子元,那麼請按照本指南進行操作。

在 bbPress 的普通安裝中,該插件會從您當前活動的 WordPress 主題中查找以下模板,並將論壇 「注入」 到它找到的第一個模板中。

它將找到具有下面列出的名稱的任何頁面模板。

  • plugin-bbpress.php
  • bbpress.php
  • forums.php
  • forum.php
  • generic.php
  • page.php
  • single.php
  • singular.php
  • index.php

對於 WordPress 主題,最常見的是將論壇代碼注入 page.php 文件。要找到確切的文件,請安裝插件 What The File 並轉到您網站的 bbPress 論壇部分並檢查您的 WordPress 工具欄,看看要修改的確切文件是什麼。

然後您可以複製您找到的文件並將其重命名為上面列出的任何文件名,並確保它位於您的主題根目錄中。

wp-content/themes/%mytheme%/bbpress.php 其中 %mytheme% 是您當前活動主題的名稱。

建議使用子主題,以免在下次更新主題時丟失任何更改。

畢竟,您可以自定義新的 bbpress.php 文件以刪除任何不需要的代碼/設計您的 bbPress 論壇,bbPress 插件應該選擇該模板並使用該自定義模板呈現其所有頁面。

示例模板

不要只是將此代碼複製並粘貼到空白模板中。所有的主題都不一樣。將其用作指南。

請閲讀代碼中的註釋。

<?php   /* * * The template for displaying all bbPress pages * * This is the template that displays all bbPress pages by default. * Please note that this is the template of all bbPress pages * and that other 'pages' on your WordPress site will use a * different template. * * @package WordPress * @subpackage Theme */     /* Self explanatory its a functions that gets your header template. */   get_header(); ?>     <?php /* Surrounding Classes for the site   These are different every theme and help with structure and layout   These could be SPANs or DIVs and with entirely different classes. */ ?>   <div id="primary" class="site-content">   <div id="content" role="main">     <?php /* Start the Loop */ ?>   <?php while ( have_posts() ) : the_post(); ?>     <?php /* This is the start of the page and also the insertion of the post classes.   Post classes are very handy to style your forums. */ ?>   <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>     <?php /* This is the title wrapped in a header tag   and a class to better style the title for your theme */ ?>   <header class="entry-header">   <h1 class="entry-title"><?php the_title(); ?></h1>   </header>     <?php /* This is the content wrapped in a div   and class to better style the content */ ?>   <div class="entry-content"> <?php the_content(); ?> </div>   <!-- .entry-content -->     <?php /* End of Page */ ?>   </article>   <!-- #post --> <?php endwhile; // end of the loop. ?>   </div>   <!-- #content -->   </div>   <!-- #primary -->     <?php /* This is code to display the sidebar and the footer.   Remove the sidebar code to get full-width forums.   This would also need CSS to make it actually full width. */ ?>   <?php get_sidebar(); ?> <?php get_footer(); ?>

為 bbPress 論壇呈現自定義模板代碼的另一種方法是在 PHP if 語句中使用條件標記,例如 is_bbpress() 。

這是一個例子。

<?php if ( is_bbpress() ) : ?>   <div class="abc">   This content should show if it is bbPress       </div>   <?php else : ?>   <div class="xyz">   This should show if it is not bbPress       </div>   <?php endif; ?>

phpBB

phpBB

phpBB
Codex Home → Getting Started → Importing Data → Import Forums → phpBB
phpBB v3.x Importer for bbPress
FAQ & Known Issues
Forums

Forum visibility such as moderator or admin only forums will be publicly visible after importing and you need to secure these manually.
『Link Forums』 will be imported as a standard forum without any URL redirect link.

Topics & Replies

『Announcement』 and 『Global』 stickies are imported as bbPress 『Super Stickies』, standard forum 『stickies』 are imported as bbPress 『Stickies』.
Custom phpBB BBCodes are not supported eg. [youtube] – You will have to manually change these yourself either before importing in phpBB or after importing into bbPress using phpMyAdmin.
Smilies are rendered as images if contained in 『code』 tags eg. :)
No file attachments are imported.
All 『Ordered Lists』

    will be displayed as numerical lists.
    You may find extra page breaks
    and paragraph

    elements in topics and replies and is less than ideal and is from the way the BBCodes are converted during the forum import conversion. You will find these primarily around 『blockquotes』 and 『lists』
    If you are using bbPress 『Show Lead Topic』 some of the formatting will be broken, it has been converted correctly and is an issue with the content-single-topic-lead.php template, see trac # (Ticket to follow).
    elements seem to be a hit and miss at the moment, they render sometimes and sometimes not depending on the import. (not very helpful I know, still digging around this issue)
    are not currently enabled to be embedded inline in bbPress by default with topics and replies, everything was converted correctly and we just need to throw some switches and push some buttons before the next release of bbPress to make it work, watch this space.

    Users

    phpBB does not support user profile support for 『First Name』 and 『Last Name』 only 『member_name』 and that will be the WordPress Username.
    Existing passwords are converted during the import so users can login to WordPress/bbPress as soon as the import and recounts have finished.
    phpBB Moderators, Groups, Ranks are not imported, any users you wish to make 『moderators』 or 『keymasters』 you will have to assign these roles manually via the main WordPress Admin User panel (/wp-admin/users.php).
    User 『Personal Messages (PM』s) are not supported or imported.
    User 『Avatars』 are also not supported 『out of the box』 by either WordPress or bbPress, if the users email address is registered with a 『Gravatar this will automatically be used by WordPress and bbPress, otherwise this is plugin territory. (See Note #1 below)
    phpBB Signatures, Location, Occupation and Interests custom profile fields are also not supported by WordPress or bbPress 『out of the box』. (See Note #2 below)

    References
    https://www.phpbb.com/community/faq.php?mode=bbcode
    Notes
    Note #1 – phpBB User Avatars
    The phpBB avatar filename used in phpBB user avatars is imported and stored in the wp_usermeta table as 『_bbp_phpbb_old_user_avatar_filename』. phpBB stores user avatars in /phpbbv3/images/avatars/upload/ and with some tom foolery I am quite sure these can be imported into WP』s media library and with the right plugin enabled quite easily.
    Note #2 – phpBB custom user profile fields stored in wp_usermeta.
    The following custom profile fields are imported into wp_usermeta and as you build your community with WordPress and bbPress, maybe BuddyPress also this should help down the road in converting these values to whatever plugins and profile extensions you decide to use.

    ICQ – 『_bbp_phpbb_old_user_icq』
    MSN Messenger – 『_bbp_phpbb_old_user_msnm』
    Occupation – 『_bbp_phpbb_old_user_occ』
    User Insterests – 『_bbp_phpbb_old_user_interest
    Location 『_bbp_phpbb_old_user_location』
    Signature 『_bbp_phpbb_old_user_signature』 (All BBCode is also converted here into HTML)

GSoC2013

GSoC2013

GSoC2013
Codex Home → GSoC2013
Table of contents

Introduction
Timeline
Ideas
Mentors

Introduction
bbPress is a fully-integrated forum plugin for the popular WordPress web software. It provides forum functionality for over a few hundred thousand WordPress sites, and is most popular for powering the WordPress.com and WordPress.org support sections.
Google Summer of Code is a program in which Google sponsors exceptional college students to develop open source code under the guidance of mentoring open source projects. This year, bbPress is hoping to be a mentoring organisation.
If you know you want to propose a GSoC project around bbPress, but aren』t sure what you want to do, check out our Ideas list below. If you have your own idea for a project, include it in your application and describe it thoroughly. You are not limited to ideas from this list.
Timeline

March 18, 19:00 UTC: Mentoring organizations can begin submitting applications to Google.
March 29, 19:00 UTC: Mentoring organization application deadline.
April 1 – 5: Google program administrators review organization applications.
April 8 19:00 UTC: List of accepted mentoring organizations published on the Google Summer of Code 2013 site.
April 9 – 21: Would-be student participants discuss application ideas with mentoring organizations.
April 22, 19:00 UTC: Student application period opens.
May 3, 19:00 UTC: Student application deadline.

Ideas
Quick Edit forums and topics on dashboard
https://bbpress.trac.wordpress.org/ticket/1394
Provide Quick Edit functionality for forums and topics.
Admin Bar Support
https://bbpress.trac.wordpress.org/ticket/1439
Add admin bar UI and improve code for marking a user as Spam.
Akismet admin UI
https://bbpress.trac.wordpress.org/ticket/1616
Finishing up the API for and building the bbPress/Akismet admin UI to display the spam history and Akismet results.
Bulk actions for forums
https://bbpress.trac.wordpress.org/ticket/1723
Provide Bulk Actions for forums, such as marking topics as closed/spam/etc.
Moderator control panels
https://bbpress.trac.wordpress.org/ticket/1721
Create a `/moderate` section for moderators to use without needing to visit the `wp-admin` area.
Direct login and register links to bbpress login or register page templates
https://bbpress.trac.wordpress.org/ticket/1756
Create direct login and register pages, and/or a sidebar Widget, for bbPress users to avoid sending them to `wp-login.php`.
Very long load times when posting replies if topic has many subscribers
https://bbpress.trac.wordpress.org/ticket/2162
Create a mail queue on `wp_cron` to avoid long loads when a new reply is posted to a topic with many subscribers.
Auto refreshing new replies
https://bbpress.trac.wordpress.org/ticket/1907
AJAX all of the things!
User signatures/sigfiles
(No ticket yet.)
Mentors

John James Jacoby, jjj
bbPress Lead Developer. Interested in projects around BuddyPress and bbPress.

Jennifer M. Dodd, jmdodd
bbPress Core Contributor. Interested in improving moderator experience and capabilities and adding popular user-requested functionality.

Daniel Dvorkin, MZAWeb
bbPress Contributor. Interested mostly in performance, AJAXifing all the things and security, but always open to fun challenges.

vBulletin

vBulletin

vBulletin
Codex Home → Getting Started → Importing Data → Import Forums → vBulletin
vBulletin v4.x Importer for bbPress
FAQ & Known Issues
Known Issues: Users must reset their password manually using /wp-login.php?action=lostpassword See #1969 for detailed password information.
Forums

Forum visibility such as moderator or admin only forums will be publicly visible after importing and you need to secure these manually.
『Link Forums』 will be imported as a standard forum without any URL redirect link.
『Locked Forums』 will be imported as like a normal open forum, again you can close/lock these via the forums panel in wp-admin and setting the forum attributes status to closed.

Topics & Replies

No file attachments are imported.

Users

vBulletin does not support user profile support for 『First Name』 and 『Last Name』 only 『username』 and that will be the WordPress Username.
vBulletin Moderators, Groups, Ranks are not imported, any users you wish to make 『moderators』 or 『keymasters』 you will have to assign these roles manually via the main WordPress Admin User panel (/wp-admin/users.php).
User 『Personal Messages (PM』s) are not supported or imported.
User 『Avatars』 are also not supported 『out of the box』 by either WordPress or bbPress, if the users email address is registered with a 『Gravatar this will automatically be used by WordPress and bbPress, otherwise this is plugin territory.
vBulletin MSN, Skype custom profile fields are also not supported by WordPress or bbPress 『out of the box』. (See Note #1 below)

References
http://www.vbulletin.com/forum/misc.php?do=bbcode
http://stackoverflow.com/questions/13920322/vbulletin-to-bbpress-conversion-how-can-i-redirect-the-old-urls-to-the-new-one
Notes
Note #1 – vBulletin custom user profile fields stored in wp_usermeta.
The following custom profile fields are imported into wp_usermeta and as you build your community with WordPress and bbPress, maybe BuddyPress also this should help down the road in converting these values to whatever plugins and profile extensions you decide to use.

ICQ – 『_bbp_vbulletin_user_icq』
MSN Messenger – 『_bbp_vbulletin_user_msnm』
Skype』_bbp_vbulletin_user_skype』