為什麼要有測試站點?

為什麼要有測試站點?

為什麼我應該有一個測試站點?

許多 wordpress 使用者只有一個實時站點,並在該站點上進行所有更改。在絕大多數情況下,這很好,而且效果很好。

但是 wordpress 論壇每天都有來自 WordPress 管理員的帖子,他們在他們的網站上進行了一些更改,但現在無法正常工作。

WordPress 核心非常強大,但是為了製作一個 wordpress 站點,我們大多數人都會新增主題和外掛(包括 bbPress),而這些是由許多不同的人編寫的。我們也可以透過新增 css 或新增函式來自己進行更改。 WordPress 還使用多種語言,將所有這些元素結合在一起意味著錯誤可能會蔓延。

因此,以下所有情況都可能導致問題:

  • 更新 wordpress 核心
  • 更新外掛
  • 更新主題
  • 新增外掛
  • 改變主題
  • 更改或新增功能
  • 更改或新增 css

雖然在大多數情況下這一切都很好,但所有這些都可能導致任何問題,從輕微的佈局問題到最壞的 “白屏宕機”(稱為 WSOD),您的網站只顯示一張空白的白紙。

對許多人來說,這是他們第一次遇到問題,他們不熟悉 FTP 和 PHPmyadmin,並且對於一個通常無法執行或看起來非常錯誤的實時站點,他們既感到恐慌、沮喪,又需要緊急幫助。

破壞您的實時站點也會在最不方便的時刻發生 – 只需兩分鐘的簡單快速外掛更新剛剛破壞了您的站點,您現在應該在十分鐘內出去吃晚飯,而您的另一半正在對您大喊大叫,讓您做好準備。

擁有測試站點意味著您可以更新 WordPress,新增或更新外掛和主題,並確保它們在您實時執行此操作之前正常工作。如果它破壞了您的測試站點,您可以花時間找出問題所在,同時您的實時站點仍能正常執行。

但是擁有一個測試站點可以讓您做更多、更多的事情。您可以測試 WordPress 、主題和外掛設定更改以檢視它們的作用;嘗試更改樣式以檢視它們的外觀;更改您的函式檔案並新增新函式;建立一個子主題並玩弄您網站的外觀和功能;新增新的 .php 檔案並在其他人看到它們之前測試它們。

當然,您可以在閒暇時執行此操作,不再需要快速嘗試某些內容,然後在您不喜歡的情況下還原您的站點。您可以做一半的更改,稍後再回來修補它。

如果以上所有內容都不能讓您相信您不僅想要一個測試站點,而且絕對需要一個,那麼讓我補充一個關鍵點——備份。

現在您可能依賴您的主機提供商來備份您的站點,我懷疑所有主機提供商都會至少每天備份您的站點。如果您的網站因為您嘗試更新外掛而出現故障並且您的網站凍結,他們會讓您恢復到昨天的版本 – 是嗎?

嗯,可能是這種情況,但是您的提供商會在幾分鐘內完成嗎?他們會一天 24 小時這樣做嗎?他們甚至在您的時區嗎?昨天的備份是否足夠好?– 是的,它可能會讓您回到更新該外掛之前的位置,但是您是否會丟失花費數小時撰寫的部落格條目,是否會丟失論壇帖子、商店訂單、讀者發表的評論、您擁有的設定改變了,css 和函式檔案?– 事實上,今天您網站上的無數事物可能與昨天不同。

最終,如果您的主機提供商破產,那麼您不僅失去了您的站點,而且他們將沒有工作人員為您提供站點的副本,以便您可以在其他地方進行設定。

因此,依靠您的主機提供商進行備份並不是一個好策略。

因此,您自己進行備份 – 是嗎?有很多備份產品,而且很多都可以作為外掛使用。您也可以自己備份 WordPress,並複製您的資料庫。

通常對於所有這些方法,您會將它們儲存到您的 PC 中,或者現在越來越普遍地儲存到 “雲” 中。但影印只是解決方案的一半。複製是否有效,您是否測試過,您知道如何進行還原嗎?這些不是您想要在現場測試或在您的網站關閉時第一次嘗試的東西。那麼您怎麼知道您的備份夥伴(可用的備份外掛之一)副本是否會在需要時實際恢復?

當我第一次開始使用 WordPress 時,我使用了這個外掛,但發現我複製的一個副本根本無法恢復——如果那是我的關鍵副本,並且我的實時站點已關閉,然後我需要走得更遠。幸運的是,我有很多其他備份夥伴副本,它們執行良好。

或者,如果您複製資料庫,您怎麼知道它們沒有損壞,或者我發現它們太大而無法一次性恢復到我的資料庫中。

除非您定期測試備份以檢視它們是否有效,否則您既不知道副本是否正常工作,也不習慣恢復過程。這兩個都是關鍵要求,如果不確定您是否可以恢復,您的備份充其量只是一種希望。

因此,測試站點可讓您測試恢復備份 – 不是每天,但您當然應該測試恢復,比如每月一次,讓您感到高興,如果最壞的情況發生,您可以應對。

因此,如果我現在已經說服您應該擁有一個測試站點,那麼您會想知道如何建立一個。

回到建立測試站點

建立測試站點

建立測試站點

建立測試站點非常有益,因為您可以瞭解 bbPress 和 WordPress 的工作原理,並同時測試它們。

  • 對於開發人員來說,建立一個測試站點可以幫助他們為 bbPress 開發外掛或主題。
  • 對於常見的 WordPress 站點調整器,它可以在將更改傳輸到實時站點之前在其測試站點上測試簡單的樣式或功能更改。
  • 更重要的是,建立一個測試站點將允許您測試外掛/主題升級的問題,以便更新不會使您的實時站點容易受到駭客的攻擊或破壞您的站點。

這個簡單的過程應該可以幫助您自信地升級,並且可以更大膽地使用您的站點,首先測試測試站點中的所有內容,只有在您對一切正常工作感到滿意後才提交到實時站點。

如果您不相信您需要一個測試站點,那麼請閱讀我的推理:為什麼要有一個測試站點?

建立測試站點有兩種流行的選擇:

  1. 在您的計算機上安裝本地伺服器環境客戶端
  2. 使用現有域的子域。

本地安裝

在您的計算機上建立測試站點是購買新域的一種很好且免費的替代方法。如果您想走這條路,您需要安裝一個支援您的作業系統的應用程式,並允許您執行主機伺服器通常安裝的軟體來在您的計算機上執行測試站點。

每個應用程式透過它支援的作業系統識別自己,並安裝軟體,包括  A pache 、 M ySQL 和 P HP(XAMPP 還包括 P erl)。以下是流行的本地伺服器環境客戶端列表,以及 WordPress 手冊中的指南連結,可幫助您安裝每個應用程式。

最流行的本地伺服器包是:

  • WAMP – 適用於 Windows
  • MAMP – 適用於 Mac
  • XAMPP – 適用於 Windows 、 Mac 和 Linux

建立測試站點並使用列出的軟體應用程式之一在您的計算機上安裝 WordPress 後,您可以安裝 bbPress 並對其進行測試。您可以看到外掛如何與 bbPress 一起工作,主題如何工作,您還可以為 bbPress 開發外掛或主題。

現有域的子域

子域將您的主域用作單獨的站點。因此,如果您建立一個名為 “test” 的子域,那麼您將使用 “test.mysite.com” 作為訪問該站點的 URL 。

大多數主機提供商允許您建立子域。如果您訪問您的託管區域,您應該會找到建立子域的選項。如何執行此操作因主機提供商而異,因此如果您需要任何幫助,請聯絡主機提供商的支援以獲取有關如何為當前設定建立子域的任何資訊。

建立後,您可以建立測試站點並獲得以下好處:

  • 測試任何效能問題
  • 包含外部源 API 的測試外掛

克隆現有站點

透過克隆或映象您的實時站點,您可以先在測試站點上測試任何修改/升級,而不會影響您現有的實時站點。

所以您可以測試:

  • 主題和外掛的新升級
  • 新增並測試任何新外掛
  • 更改已安裝的 WordPress 主題
  • 新增 css 、更改功能、佈局以及與現有 WordPress 站點有關的任何內容

因此,您將首先僅在測試區域提交,如果您對結果感到滿意,則可以將這些更改轉移到您的實時站點。而且,如果外掛有新的升級,您可以先在您的測試站點上測試升級,如果升級導致問題,您將知道在問題解決之前不要在您的實時站點上升級。

複製資料

所以現在您有一個測試域,其中包含您網站上的所有檔案和資料夾,但您需要複製資料。

嘗試操作

  1. 使用 phpMyAdmin 訪問您的實時站點的資料庫。
  2. 接下來,在左側,您將看到所有建立的資料庫。
  3. 查詢並選擇您的實時站點的資料庫,您現在將看到來自該資料庫的一系列表格。
  4. 您將在頂部的選單中看到一個匯出選項。單擊它後,您將看到一些選項。
  5. 現在您可以進行快速匯出,但我認為不建議這樣做,我更喜歡您進行自定義匯出,以允許您將資料壓縮為 zip 格式並新增任何其他值以改進恢復。
  6. 所以現在啟用 Custom 。
  7. 通常,您可以將資料庫匯出到單個包中,但是如果您有一個特別大的資料庫,您可能無法一次性匯出/匯入。在匯入過程中,您可能需要複製單個資料庫表或對錶進行分組。但是,您可以先嚐試匯出所有表以進行測試並確保一切正常。
  8. 在 “輸出” 部分中,選擇您選擇的 zip 格式來壓縮您的資料庫資料。這可能會顯著增加大型資料庫的上傳時間。它還可以讓您克服主機提供商可能設定的某些檔案上傳大小限制。
  9. 在物件建立選項中,啟用新增 DROP TABLE/VIEW /PROCEDURE/FUNCTION/EVENT 語句。在匯入過程中,這將在恢復新表之前刪除所有現有表,確保匯入乾淨。
  10. 現在單擊 Go,檔案將下載到您的計算機上。

匯入資料

已經以壓縮檔案格式下載了資料庫資料,您現在可以將資料匯入到新的或現有的資料庫中。

如果您尚未建立新資料庫。

  1. 轉到 phpMyAdmin 主頁。
  2. 單擊頂部的資料庫選單項
  3. 您現在將看到一個用於建立新資料庫的區域以及一個用於命名資料​​庫的文字輸入。
  4. 為測試站點的新資料庫建立一個新名稱。將下拉選單保留為 Collat​​ion 的預設設定,然後單擊建立按鈕。
  5. 您剛剛建立了新資料庫。

將資料匯入新資料庫。

  1. 為您的測試站點選擇您最近建立的資料庫。
  2. 單擊頂部的匯入選單項
  3. 現在單擊 “選擇檔案” 按鈕 ,然後從下載中選擇實時站點的資料庫資料。
  4. 單擊 “前往” 按鈕。等待匯入完成,然後您應該會看到一條成功訊息。
  5. 現在,您已將實時站點的資料庫資料匯入到測試站點資料庫中。

更改站點引用

由於活動站點的資料已匯入到測試資料庫中,您將在 wp_options 表中看到您的活動站點的 url 。如果您不更改這些,您將被重定向到您的實時站點,因此更改它是關鍵。

  1. 在 phpmyadmin 中選擇您的測試站點資料庫
  2. 單擊最頂部的 SQL 選單項
  3. 現在在空框中輸入以下 SQL 程式碼
UPDATE wp_options SET option_value = REPLACE(option_value, 'LIVESITE_URL', 'TESTSITE_URL'); UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'LIVESITE_URL', 'TESTSITE_URL'); UPDATE wp_posts SET guid = REPLACE(guid, 'LIVESITE_URL', 'TESTSITE_URL'); UPDATE wp_posts SET post_content = REPLACE(post_content, 'LIVESITE_URL', 'TESTSITE_URL');

TESTSITE_URL 是您的測試站點的完整 URL 地址。

LIVESITE_URL 是您的實時站點的完整 URL 地址。

如果您對測試站點的資料庫使用不同的內容,則可以更改 wp_ 字首。

安裝 WordPress

完成建立測試站點的資料庫後,您需要安裝 WordPress 。這將允許您在安裝期間輸入新資料庫資訊。您可以手動執行此操作,也可以使用主機提供的 WordPress 安裝過程。
傳輸檔案

  1. 首先使用 FTP 或 SFTP 客戶端下載您的實時站點的 wp-content 資料夾的副本。
  2. 然後將您下載的資料夾內容上傳到您的測試站點的 wp-content 資料夾。所有重要的檔案,如主題、外掛和媒體上傳都將透過此傳輸。

其他步驟

設定測試站點後,您需要禁止使用者訪問和搜尋機器人索引測試站點。

  1. 在儀表盤 > 設定 > 閱讀中更改搜尋引擎可見性以阻止搜尋引擎索引您的測試站點。並且保持禁用任何 SEO 外掛/功能應該會有所幫助。
  2. 由於這是一個測試站點,您不會允許任何人註冊到您的站點。因此,安裝 Restrict Site Access 將允許您將站點限制為您的 IP 地址,並且只允許您訪問您的測試站點。

Step by step guide to setting up a bbPress forum – part 5

Step by step guide to setting up a bbPress forum – part 5

Step by step guide to setting up a bbPress forum – part 5
Codex Home → Step by step guide to setting up a bbPress forum – part 5
1. Using  Filters
Actions and Filters add a powerful way that you can alter how bbPress (and of course WordPress) work.
For the newcomer to WordPress, they are also probably one of the hardest areas to understand and to find information on. This tutorial tries to demystify some of this area, and help newcomers code those changes that will make their site work how they wish.
Part 4 dealt with ‘actions’, this section deals with ‘filters.’
It does repeat some of the initial text in Actions as it is applicable to both.
2. Introduction.
If you are familiar with functions and filters, you’ll probably not need to read much of this article, but I presume if you’re here, then like me you see snippets and ‘brief’ explanations that get you to the stage where you are pretty sure what you want can be done, but can’t quite work out the exact way or get it to work.
So at this stage, make a cup of coffee, shut the kids out of the room, and I’ll try and take you through what I have learnt so far about filters.
If you can improve either the explanation, correct any errors I have made, or help in any other way, just post a topic on “requests and feedback” on the support forums, and I’ll pick it up.
3.  Filters
If actions ADD stuff at a particular point (see part 4 ), Filters are a way to ALTER what is being displayed (typically which bits of data or the format/order) at a particular point, without needing to change the code in the file.
This can be very handy if

the data is displayed in multiple places (eg the way an author name is displayed) – you change it once for all occurances
the file you want to alter is in the core of the code, so you don’t want to change the original file
You start to write plugins for others to use – filters let you alter lots of coding without touching the actual php files

So in essence think of it that actions add and filters alter.  But what does  a filter actually filter?  Well it filters a function, so we need to understand functions before we move forward
4. An explanation of functions
A function is a bunch of code that when combined does something.  In WordPress, functions are used to both hide complexity,  save repeating endless lines of code all over the place, and improve manageability.
So in bbpress the lines of code that go to the database, and fetch the identity of the author of a post is all put into a function  called  bbp_get_reply_author_id.  Anytime we want to do this, we can just quote that function, and save ourselves using many lines.  And if the guys behind bbPress want to change how that works, they do it just once and all the instances that use this then use the new function.
So lets create a simple function (we’ll get to some real bbPress examples later!)
function hello () {
$text=”Hello Robin” ;
echo $text ;
}
Line 1 creates the function
Line 2 sets a variable of $text to Hello Robin
Line 3 writes that text to the screen
Then whenever called within a wordpess php file eg
hello () ;
it will write the result.
We might put this function in our functions.php file, or put it within a plugin.
Now bbPress is a plugin, and in bbPress there are hundreds of functions in many locations.
So imagine that someone else has written the ‘hello’ function above and buried this function in in their plugin, and that this function is used in many places. However you don’t want it to say “Hello Robin” but “Hello Fred”. Now you could find the function within the plugin and alter the code in the file, but on any upgrade of the plugin, you’ll lose the changes. So it would be better if you could just alter that variable $text, and filters offer a way to do that.
5. Not all functions are filterable
The above function cannot be filtered as it has not been written to allow this – hopefully all the functions you will come across have been – so let’s re-write it to be filterable.
function hello () {
$text=”Hello Robin” ;
$text=apply_filters(‘hello’,$text) ;
Echo $text ;
}
Line 3 has been added. In essence it says that if a filter exists, then substitute the value of $text in that filter to the function.
So now if we create a filter and add a function to it that changes $text, whatever value of $text is in that filter replaces the original value of $text in the function. So we can make “Hello Robin” become “Hello Fred” without altering any code.
So lets create a filter for this.  As with actions, we do this by creating a function.
So the original code above is buried in someone else plugin. Our new code will sit in our functions file or in a plugin, and alter the effect of that original code, changing $text=”Hello Robin” to $text=”Hello Fred”.
So the resultant code looks like
//function to change ‘Hello Robin’ to ‘Hello Fred’ in ‘hello’ function
function called_anything () {
$text=”Hello Fred” ;
return $text ;
}
add_filter(‘hello’,’called_anything’) ;
So lets run through this.
5.1 Names
First let’s deal with naming
We are creating a function, and functions can be called anything.  However every function (and there are thousands of them in there already) MUST have a unique name across your website.  Given that you have the core wordpress and probably lots of plugins, it is important that you don’t create a duplicate name.  Calling it something like in my case ‘robin_w_hello’ would probably make it pretty unique.
Adding a comment line at the start of your function to remind you what this is doing is also important, as you’ll never remember what this bit does when you start to have lots of these in your files.
5.2 Bringing in variables
In line 1 we called our function using function called_anything () .  The () is the area in which to put any variables we want to bring into our function.  So if I wanted to alter $text rather than replace it, I’d put it into the () so that it was brought in ie function called_anything ($text). In this case I could then  use some string manipulation to say strip the hello from the front.  So if you want to manipulate data from the core function import them here.
5.3 Return the data
Line 3 includes a return command.  This ensures that the data is passed back to the main function.  If omitted, then any variables you were planning to change will be blank, and therefore not show.
5.4 Add_filter &  Remove filter
In the last line we add a filter to ‘hello’  named ‘called_anything’
In this case we are adding filter. There is another command called remove_filter for removing a filter – useful if someone else’s plugin has a filter that makes a change you don’t want.
6. The apply_filter can have a different name from the function !
Ok so if you are not going mad by now, you are applying a filter with a name to your function, not applying a filter to your function’s name. So that apply_filter can have a different name from your function, and indeed you can have several filters in a function.
So whilst we had a line above in our function ‘hello’ saying
$text=apply_filters(‘hello’,$text) ;
the ‘hello’ bit of “apply_filter(‘hello’” is the name of the filter, and could be anything (or rather anything unique to your site!)
So whilst no one would actually write a function this way, we could have
function hello () {
$text1=”Hello Robin” ;
$text1=apply_filters(‘hello_change1’,$text) ;
$text2=”goodbye Robin” ;
$text1=apply_filters(‘hello_change2’,$text) ;
Echo $text1.$text2;
}
Now I wouldn’t tell you this unless you needed to know it, so you will frequently find filters in wordpress and bbPress are not the same as their function name. Indeed we will see later on that they are quite often different, but have a logic to them, which once known means that you can work it out.
7. Creating a filter for an array
An array is a set of data held within a single data name
So for instance
$data = array(
“name” => “Robin”,
“age” => “21”,
);
The array $data now contains both my name and my age.
Most bbPress functions create arrays, as they use multiple data, so lets create a function that has an array, and outputs some data
function hello () {
$data = array(
‘name’ => ‘Robin’,
‘age’ => ’21’,
‘text’ => ‘ years old.’,
);
$data=apply_filters(‘hello’,$data) ;
echo $data[‘name’].” is “.$data[‘age’].$data[‘text’] ;
}
Calling hello() in a php file will cause the result
“Robin is 21 years old.”
Let’s say we want to change the wording to say “Robin is 21 years young.”
So we need to alter the $data[‘text’] to say ” years young.”
So we will write a function to do that, and the add a filter to implement it
The result looks like this
//this adds a filter to change $data[‘text’] to ‘ years young’
function called_anything ($data) {
$data [‘text’] = ‘ years young.’ ;
return $data ;
}
add_filter(‘hello’,’called_anything’) ;
Let’s run through that
If we just had ‘function called_anything()’ then anything we change we will reset the entire array, so we need to ‘bring in’ the current values. ‘called_anything ($data)’ brings across the array into our new function.
The second line changes the ‘text’ value, and the third line returns the new array back to the original function
So now the array looks like
‘name’ => ‘Robin’,
‘age’ => ’21’,
‘text’ => ‘ years young.’,
and the output will be “Robin is 21 years young” – job done !
So now we’re ready to look at some real bbPress examples.
8. Finding the code
So where is the code that we need to look at?
This is of course the first issue with bbPress (as with any other part of WordPress) – finding out what file needs to be altered.
For bbPress, all the critical template files (the most likely you’ll want to alter) are held in the folder
Wp-content/plugins/bbpress/tempaltes/default/bbpress
Whilst many of the names give a good clue to what they do, you’ll probably need to delve into a few before you find the one you want.
I plan to make a list of these templates and what they do if/when I work it out!
But let’s start from the point where you have got something displaying in WordPress that you want to alter. You have found the template file that covers this, and within that you have a function that is displaying the data that you want to alter or alter the display of.
So we’ll need to create a filter.
9. Where to add filters
In this tutorial, we’ll generate the code you need, but obviously that code needs to go somewhere. So where do we put it?
We add actions or filters either to the functions file, or create them as a plugin.
Both methods have their uses.
If you like using plugins, then they’re a good way to add changes, and work well if you have a number of sites, as the plugin is easily uploaded to each. But they do require a bit more knowledge to code. But google the subject and you’ll find lots of help on creating one. Then just put the code into it, and upload to your site.
The alternate is to use a functions file. As you are now at the “advanced” stage of using WordPress, you should either be developing your own themes, or using a Childtheme to store the specifics.
If you still just have a main theme from someone else (eg a wordpress default theme, a free theme or a premium theme), then you should create a childtheme. This simply uses the main theme, and the you can add your tweaks to the childtheme. Then if the main theme is updated, you tweaks in the childtheme are not overwritten. For help on creating a childtheme google “child theme wordpress video” and you’ll find lots of demonstrations. If someone has built a site for you, it may already be a in a child theme, and again the video’s will let you see whether this is the case.
Within our childtheme, we’ll put a functions.php file, and the actions and filters we set up will go in there.
10. Example of code we can alter
So to start to understand what we need to do, lets have a look at something we might want to change
In the forums display we have a count of topics and replies next to each forum viz :

Let’s say we want to remove these counts and make it look like

Now we could do this by altering the template that does this. In fact the codex has a page Layout and functionality – Examples you can use . Section 2 shows how to change this by altering a template called loop-single-forum. But if we alter that template, then we will need to store it in a different place so that it is not overwritten by later updates. This can be quite easily done, and there is no reason why you shouldn’t do this, but adding a filter is an equally valid alternative.
So where to start?
Well let’s start by summarising what we are going to do, then you can follow the steps.
a) look at the templates to find which one has the function we want to alter
b) look at the codex to see if that function is there
c) if it is then we can see the arguments,
d) if not, then we’ll need to look for the function definition
e) and then code the filter
Looks easy(ish), but it’s a bit like being a detective, you have to follow the clues.
a) Well we start by finding out that bbPress stores all the main “display” areas of the plugin in a template folder held at
wp-content/plugins/bbpress/templates/default/bbpress
I plan to have a list of which templates do what, but for the moment it’s really a case of intelligent guesswork and lots of opening files and examining. Typically anything with lists in it will be running a loop (going through a list), so loop-something is a good bet.
So since we are loking at a list of forums, we loom at the templates that have loop and forum. At some stage we open loop-single-forum and in there we see a progression from forum title, forum description, sub-forums, and then some topic, reply and freshness counts.
Click here to see the file – opens in a new window so you can switch between this and the code.
The sub-forum list part on line 30
bbp_list_forums();
looks like a likely candidate, so let’s look at that. We’ll do that next.
b) So lets look at the codex to see what is written about this function. Go to the documentation (this section) and select any article – you’re actually reading this one, so that’s fine. On the left hand side you’ll see a “related” area. You’ll need to scroll back up from this article to see it. Look down the list for the function – in this case ‘bbp_list_forums’, and it’s listed (not all are – yet!)
Open this up and you’ll see that it lists the arguments (again not all do yet, so see d) below if yours is not there.

Within this are “show topic count” and “show reply count”, and you’ll see that they are set to “True” – setting these to false should hide the detail.
You’ll also see a line saying “To filter this array use add_filter(‘bbp_before_list_forums_parse_args’, ‘your_filter_name)” – so that’s the filter we need. As we said earlier, the filter name may well be different to the function name. So bbp_list_forums uses ‘bbp_before_list_forums_parse_args’ to alter the array. (In fact there is a further filter in this function which does have the function name, but we’ll ignore that for the moment!)
So we’ll create a function to change the topic and reply values to false so that they don’t display and add a filter to implement it.
The data is held in an array, so we need to use the code for that.
So lets start with the function
function hide_forum_counts ($args = array() ) {
$args[‘show_topic_count’] = false;
$args[‘show_reply_count’] = false;
return $args;
}

Then we’ll add the filter
add_filter (‘bbp_before_list_forums_parse_args’,’hide_forum_counts’) ;
This code will go in our functions file (or as a plugin).
d) But what if the codex doesn’t show the filter? How do we find what filter to use?
Ok, we can work this out. We’ll start as before with bbp_list_forums. We need to fund where that function is defined.
Now all the functions used in the templates wp-content/plugins/bbpress/templates are held in 5 template folders that are located as follows :
wp-content/plugins/bbpress/includes/forums/template.php
wp-content/plugins/bbpress/includes/topics/template.php
wp-content/plugins/bbpress/includes/replies/template.php
wp-content/plugins/bbpress/includes/users/template.php
wp-content/plugins/bbpress/includes/search/template.php
As we are listing forums, we could take a bet that it will be in wp-content/plugins/bbpress/includes/forums/template.php (which it is), but if you had no clue, then download the plugin to your PC, extract it to a directory, and use your PC’s serach function to find it. But do search for ‘bbp_list_forums’ not ‘bbp_list_forums()’ as bbPress functions will normally have arguments, so the () will contain stuff, and your search will produce a nil return!
So we find wp-content/plugins/bbpress/includes/forums/template.php
and open it up. Inside we see on line 744
function bbp_list_forums( $args = ” ) {
and way down on line 801
echo apply_filters( ‘bbp_list_forums’, $r[‘before’] . $output . $r[‘after’], $r );
so we’d think that the filter we want to add is to “apply_filters( ‘bbp_list_forums’”. But no, this filter is after all the function has happened. We simply want to change a couple of the input parameters.
At the beginning of the function we find :
// Parse arguments against default values
$r = bbp_parse_args( $args, array(
‘before’ => ‘<ul class="bbp-forums-list">’,
‘after’ => ‘</ul>’,
‘link_before’ => ‘<li class="bbp-forum">’,
‘link_after’ => ‘</li>’,
‘count_before’ => ‘ (‘,
‘count_after’ => ‘)’,
‘count_sep’ => ‘, ‘,
‘separator’ => ‘, ‘,
‘forum_id’ => ”,
‘show_topic_count’ => true,
‘show_reply_count’ => true,
), ‘list_forums’ );

This is a common format throughout bbPress, and indeed is similar to a function used throughout wordpress.
It uses a function called ‘bbp_parse_args’ to create a filter against all the arguments.
The filter created is in the format “bbp_before_” followed by X followed by “_parse_args” The X is the third argument from the bbp-parse_args function – if you look at the code aboave you’ll see that it is actually
bbp-parse_args ($args, Array(…), ‘list_forums’ )
so in the last line we see ‘list forums’ which is the X above . In practice this is the function without the bbp start bit.
so an array filter for bbp_list_forums is ‘bbp_before_list_forums_parse_args’
and for say bbp_get_topic_pagination would be
bbp_before_get_topic_pagination_parse_args
Ok, so that’s a long explanation, that will need you to read several times, and I’ll add some more examples as I progress.
As said above, any feedback or clarity needed, post a topic at
requests and feedback

Tender

Tender

Tender
Codex Home → Getting Started → Importing Data → Import Forums → Tender
Tender 0.7 Importer for bbPress
https://github.com/JustinSainton/Tender-to-bbPress-Importer/
Uses Tender‘s neat JSON API to import discussions into bbPress

Custom Capabilities

Custom Capabilities

Custom Capabilities
Codex Home → Custom Capabilities
Whilst bbPress provides a good set of forum roles, with distinct capabilities, you may want to amend these or add new names.
However the latest combination of WordPress and bbPress does not work if the code to do this is in the functions.php file of the child theme (or indeed parent theme!).
If you put this code in a plugin, it seems to work fine.
If you are comfortable in changing files and FTPing them to your site, then visit bbpress role adder – Robin W’s website (rewweb.co.uk) for a plugin and template that should work
Adding new names
At the simplest levels, you can add a new role name and give it existing capabilities
This can be useful just for your own admin purposes, but also if like me you hate the “keymaster” role name, just create a new role and give it keymaster capabilities.
The following code creates three new roles with names ‘name 1′,’name 2′ and ‘name 3′ the first role has participant, the second moderator and the third keymaster.
Simply amend the code to create as many roles with whatever capabilities you need
add_action (‘wp_loaded’ , ‘load_new_roles’) ;
function load_new_roles ()
{
add_filter( ‘bbp_get_dynamic_roles’, ‘add_custom_role’, 1 );
}
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;
}
Creating new roles
If you want to add a new roles with specific capabilities, then you can add these
The code below adds a role called ‘tutor’ simply change the word tutor wherever it occurs to the name you want and decide what capabilities you want to the role to have.
//code to add tutor role

add_action (‘wp_loaded’ , ‘load_new_roles’) ;

function load_new_roles ()
{
add_filter( ‘bbp_get_dynamic_roles’, ‘add_new_roles’, 1 );
add_filter( ‘bbp_get_caps_for_role’, ‘add_role_caps_filter’, 10, 2 );
}
function add_new_roles( $bbp_roles )
{
/* Add a role called tutor */
$bbp_roles[‘bbp_tutor’] = array(
‘name’ =>’Tutor’,
‘capabilities’ =>custom_capabilities( ‘bbp_tutor’ )
);

return $bbp_roles;
}

function add_role_caps_filter( $caps, $role )
{
/* Only filter for roles we are interested in! */
if( $role == ‘bbp_tutor’ )
$caps = custom_capabilities( $role );

return $caps;
}

function custom_capabilities( $role )
{
switch ( $role )
{

/* Capabilities for ‘tutor’ role */
case ‘bbp_tutor’:
return array(
// Primary caps
‘spectate’ => true,
‘participate’ => true,
‘moderate’ => false,
‘throttle’ => false,
‘view_trash’ =>false,

// Forum caps
‘publish_forums’ =>false,
‘edit_forums’ => false,
‘edit_others_forums’ => false,
‘delete_forums’ => false,
‘delete_others_forums’ => false,
‘read_private_forums’ => true,
‘read_hidden_forums’ => false,

// Topic caps
‘publish_topics’ => true,
‘edit_topics’ => true,
‘edit_others_topics’ => false,
‘delete_topics’ => false,
‘delete_others_topics’ => false,
‘read_private_topics’ => true,

// Reply caps
‘publish_replies’ => true,
‘edit_replies’ => true,
‘edit_others_replies’ => false,
‘delete_replies’ => false,
‘delete_others_replies’ => false,
‘read_private_replies’ => true,

// Topic tag caps
‘manage_topic_tags’ => false,
‘edit_topic_tags’ => false,
‘delete_topic_tags’ => false,
‘assign_topic_tags’ => true,
);

break;

default :
return $role;
}
}
The code below adds two roles, tutor and pupil. Using this you should be able to add any number of roles
add_action (‘wp_loaded’ , ‘load_new_roles’) ;

function load_new_roles () {
add_filter( ‘bbp_get_dynamic_roles’, ‘add_new_roles’, 1 );
add_filter( ‘bbp_get_caps_for_role’, ‘add_role_caps_filter’, 10, 2 );
}
function add_new_roles( $bbp_roles )
{
/* Add a role called tutor */
$bbp_roles[‘bbp_tutor’] = array(
‘name’ =>’Tutor’,
‘capabilities’ =>custom_capabilities( ‘bbp_tutor’ )
);

/* Add a role called pupil */
$bbp_roles[‘bbp_pupil’] = array(
‘name’ =>’Pupil’,
‘capabilities’ =>custom_capabilities( ‘bbp_pupil’ )
);

return $bbp_roles;
}

function add_role_caps_filter( $caps, $role )
{
/* Only filter for roles we are interested in! */
if( $role == ‘bbp_tutor’ )
$caps = custom_capabilities( $role );

if( $role == ‘bbp_pupil’ )
$caps = custom_capabilities( $role );

return $caps;
}

function custom_capabilities( $role )
{
switch ( $role )
{

/* Capabilities for ‘tutor’ role */
case ‘bbp_tutor’:
return array(
// Primary caps
‘spectate’ => true,
‘participate’ => true,
‘moderate’ => false,
‘throttle’ => false,
‘view_trash’ =>false,

// Forum caps
‘publish_forums’ => false,
‘edit_forums’ => false,
‘edit_others_forums’ => false,
‘delete_forums’ => false,
‘delete_others_forums’ => false,
‘read_private_forums’ => true,
‘read_hidden_forums’ => false,

// Topic caps
‘publish_topics’ => true,
‘edit_topics’ => true,
‘edit_others_topics’ => false,
‘delete_topics’ => false,
‘delete_others_topics’ => false,
‘read_private_topics’ => true,

// Reply caps
‘publish_replies’ => true,
‘edit_replies’ => true,
‘edit_others_replies’ => false,
‘delete_replies’ => false,
‘delete_others_replies’ => false,
‘read_private_replies’ => true,

// Topic tag caps
‘manage_topic_tags’ => false,
‘edit_topic_tags’ => false,
‘delete_topic_tags’ => false,
‘assign_topic_tags’ => true,
);

/* Capabilities for ‘pupil’ role */
case ‘bbp_pupil’:
return array(
// Primary caps
‘spectate’ => true,
‘participate’ => true,
‘moderate’ => false,
‘throttle’ => false,
‘view_trash’ => false,

// Forum caps
‘publish_forums’ => false,
‘edit_forums’ => false,
‘edit_others_forums’ => false,
‘delete_forums’ => false,
‘delete_others_forums’ => false,
‘read_private_forums’ => true,
‘read_hidden_forums’ => false,

// Topic caps
‘publish_topics’ => true,
‘edit_topics’ => true,
‘edit_others_topics’ => false,
‘delete_topics’ => false,
‘delete_others_topics’ => false,
‘read_private_topics’ => true,

// Reply caps
‘publish_replies’ => true,
‘edit_replies’ => true,
‘edit_others_replies’ => false,
‘delete_replies’ => false,
‘delete_others_replies’ => false,
‘read_private_replies’ => true,

// Topic tag caps
‘manage_topic_tags’ => false,
‘edit_topic_tags’ => false,
‘delete_topic_tags’ => false,
‘assign_topic_tags’ => true,
);

break;

default :
return $role;
}
}

WP Symposium

WP Symposium

WP Symposium
Codex Home → Getting Started → Importing Data → Import Forums → WP Symposium
WP Symposium v14.x Importer for bbPress
Topics

WP Symposium ‘Group Topics’ from Groups are not imported.

Replies

WP Symposium ‘Forum comments’ or ‘Replies to replies’ and/or ‘Threaded replies’ are not imported.

e107

e107

e107
Codex Home → Getting Started → Importing Data → Import Forums → e107
e107 v1.x Importer for bbPress
Placeholder Text
e107 v2.x Importer for bbPress
e107 v2.x Importer ‘In Progress’ See #2422

Codex Standards & Guidelines

Codex Standards & Guidelines

Codex Standards & Guidelines
Codex Home → Participate & Contribute → Codex Standards & Guidelines
Contributing to the Codex
If you are considering contributing to the codex this simple guide is here to help you with the formatting of pages and standards & conventions to follow to keep a set appearance to pages.
The Codex is curated by the bbPress community if you are unsure about the status of an article head over to the forums and post a topic and add the topic tag codex, if you want to follow along with the codex development discussions you can visit this link or subscribe to the codex RSS feed.
Please note: All entries to the Codex are covered by the GNU General Public Licence. All entries may be edited or altered by other contributors.
How to Create a New Codex Article

Log in using your WordPress username and password.
Click on the “Create New Page” link in the sidebar.
You can also copy the example template layout from this template to get started quicker.
Add the Title of your article.
Add the article metas: Versions, Components, Types and Context. Meta boxes are located on the screen’s right sidebar. Note, try to keep these as generalised as possible for example, setting the version to ‘2.5’ is preseumed to include 2.5 and all incremental version such as 2.5.1, 2.5.2, etc.
Add your article in the appropriate codex section in the Page Attributes meta box under the Context box. If you are unsure where you should add your article head over the handbook Table of Contents for a guide or head over to the forums and create a topic with the codex topic tag and we will try to work out the best place for your article.
Add content of your article. Check that it follows the Codex General Guidelines, Codex Conventions, and Formatting guides posted below for your reference.
After you’re done, click on the “Publish” button.

How to Edit/Update an Article in the Codex

Log in using your WordPress username and password.
Navigate to the page you want to edit/update.
Click on the “Edit This Page” link in the sidebar. The link displays for the users having article edit access.
After you have made the edit/update, please double-check that the Versions, Components, Types and Context are correct and updated as well, again try to keep these broadly focused so they are easily discovered.
Click on the “Update” button in the Publish meta box.

General Guidelines
Broad guidelines on writing for the bbPress Codex

When writing articles please use the second-person point of view to address the reader. e.g. “Now navigate to your” Rather than “Now navigate to our“.
When writing technical articles (functions, actions, etc.) please use the draft template you will find in the dashboard, copy and paste it’s body outline markup to your new post.
Please keep styling to a minimum, avoid inline styling of elements unless to provide something like a color highlight if thought necessary to lend further emphasis to a piece of text e.g styling a warning in red Ensure you have backed up your DB. Please use elements sparingly , are typographic conventions and used to embolden text and italicize text for foreign & scientific words/phrases; , are to lend weight or importance to a word or phrase i.e ’em’ is not used simply to visually style text in italics.
Links: External resource links: Provided to the bottom of the article framework is a section for links to external resources, please use this section for any links to resources that help further however please ensure that these links are additional resources and that your article does not depend on them for all or any part of your article explanation, the reasoning here is external links are not guaranteed to always be available and if the article relies on them and they are down then the article is effectively useless for users. Links that are not related directly to the article content are to be avoided and if found will be removed.
Images: Do add images to articles where they help to illustrate your points or explanations, nothing helps illustrate things better than a timely graphic, screen shots of bbPress, BuddyPress, or WordPress screens help to show the reader layouts. As with links please avoid calling remote images, always upload to the media library, and embed. If uploading images please ensure you have the right to do so and are not infringing on any copyrights that may exist. Any images thought to be or that are under copyright will be removed from pages.
Creating pages: When creating pages , please ensure you select a suitable ‘Version’ tag, and optionally select from available ‘Components’ tags & ‘Types’. Please only select a parent category from the available parent sections, We request that authors DO NOT create new pages that act as parent pages for their article/s, this is to ensure the integrity of the codex structure, however it may be possible to expand the structure if thought beneficial, but please make a request for this to one of the Codex curation team members for consideration.

Codex Conventions

Website Example Names: Always use example.com, example.org or example.net wherever you need to state a domain as an example. This is per RFC 2606. For example, pun intented checkout http://example.com, these are reserved domain names intented for this specific purpose and do not link to any particular host or adfarm.
Admin: The main admin user of a WordPress site always has the login admin. (In examples. A login of admin on a live site has negative security implications.).
Using people’s names in examples: When a name is needed for an ordinary, non-admin user, or a person, use Harriet as the first name, and Smith as the last name.
Administration Panels: The WordPress interface is called Administration Panels not admin panels or dashboard. Dashboard is a specific panel within Administration Panels. Individual panels are also called Administration Screens.
WordPress is spelled WordPress: WordPress is spelled with two capital letters: WordPress.
bbPress is spelled bbPress: bbPress is spelled with only a single capital P dangit letter: bbPress.
BuddyPress is spelled BuddyPress: BuddyPress is spelled with two capital letters: BuddyPress.

Formatting Guide
If writing a technical guide please use the template format provided in this draft document ( copy paste to new page ) Codex template – technical examples layout
1. Heading Tags:
When you use h2 as a heading tag a section in the contents sidebar and link will be automatically created for you. Use h3 – h6 for sub headings of sections under the h2’s.
2. Code examples: Surround your code with the appropriate shortcodes
[php] your PHP code [/php]
[html] your HTML code [/html]
Also available are bash, shell, css, diff, patch, js, javascript, plain, text, sql and xml and are used in the same format as the previous examples.
When adding code examples please escape angle brackets with Numeric/Decimal entities rather than ‘Named ones, so use .
3. Lists: Use unordered, ordered and delimited lists where appropriate.
4. File names: Surround file names with the code tags
index.php
5. The structure of a technical guide
[Intro]
a brief intro to the guide
[/Intro][Functions]
List the functions, location, params etc.
[/Functions][Your Content]
The content body – explanation/guide.
[/Your content]
[Example Usage]
Provide a simple example of code use – using pre/code tags.
[/Example Usage]
[Additional Resources]
Add any links to off site or internal pages that might help further.
[/Additional Resources]

Flagging articles – adding article header messages
Page may be tagged in the body with two ‘Notes’
1/ This page is a legacy document, at top of page, example, if a page is deemed to be outdated or superseded by bbPress versions, or changes then it may be marked with this code block and the page would be re-assigned under the parent section ‘legacy’

This is Legacy Document, the details in this page have either been updated or are deprecated completely. Legacy Docs are retained for historic reference

2/ This page is in need of updating
A page is considered incomplete or needs to be verified for detail.

This page is incomplete or needs checking and verifying.

支援論壇

支援論壇

此頁面是支援論壇的歡迎資訊 。本介紹旨在幫助您在論壇中找到自己的方式,並希望讓您儘快入門。 bbPress 支援論壇將遵循 WordPress 支援論壇制定的相同規則和準則。請閱讀這兩頁以熟悉這些指南。使用支援論壇和  論壇歡迎

歡迎論壇志願者

感謝您花時間在 bbPress 論壇上提供支援。請注意,WordPress 支援論壇中設定的規則和指南也適用於此處。以下文件將幫助您瀏覽我們的論壇。

1. 論壇歡迎 ——本文件部分針對那些在論壇上尋求支援的人,但包含有關幫助、何時可以刪除或關閉話題以及報告執行緒等的資訊。除非問題特定於 WordPress,否則請忽略郵件列表資訊。

2. WordPress 支援手冊 ——其中包含大量文章,可幫助您為 “WordPress 方式” 提供支援。您可能想先閱讀的一些文章:

論壇版主

感謝您接受邀請成為我們支援論壇的版主 ????

請花點時間閱讀上面和下面的推薦文章,重新熟悉我們的論壇規則。如果您有任何問題或建議,請隨時聯絡 bbPres 核心團隊。

附加參考:關於提問的公認約定

閱讀下面的這份文件是值得的,它可以作為在論壇和列表上提問的正確方法的入門指南。雖然它的目標是將海報作為指導如何表現和形成一個將獲得積極響應的問題,但它對所有人都非常有用,並被視為 RFC:
如何以聰明的方式提出問題

函式檔案和子主題 – 解釋!

函式檔案和子主題 – 解釋!

建立子主題和函式檔案

許多 wordpress 和 bbpress 支援答案告訴您將一些程式碼新增到您的函式檔案或 style.css 但是什麼是函式檔案,什麼是 style.css 檔案 – 我如何建立它們以及將它們放在哪裡?

本教程希望回答所有這些問題以及更多問題!

什麼是函式檔案?

函式檔案只是一個名為 Functions.php 的檔案,它位於您的主題中。這使您可以向 wordpress 和 bbpress 新增其他功能,而無需更改這些檔案中的程式碼。如果您更改 bbpress 和 wordpress 中的程式碼,它可能會在任何更新時被覆蓋,並且您將丟失它。

現在由於函式檔案屬於主題,它同樣有可能在主題升級時被覆蓋,因此出於這些原因,最好的做法是建立一個子主題(如果您還沒有),並在其中放置一個函式檔案。

什麼是 Style.css 檔案?

每個主題都有一個 style.css,但外掛也可以新增額外的樣式檔案。這些檔案共同決定了頁面的外觀,例如元素在頁面上的位置,是否有任何填充以使其與其他文字分開,文字應該是什麼字型、顏色和大小,各種標題的樣式等. 樣式檔案也可以隱藏東西,所以有時我們可能會建議您將元素更改為 ‘display:none’ 以便它被隱藏。與函式檔案一樣,樣式檔案可能會被主題或外掛升級覆蓋,因此不建議為不是您自己編寫的主題或外掛帽更改這些檔案。因此,與函式檔案一樣,最好的做法是建立一個子主題(如果您還沒有),並且為此您將擁有一個用於該主題的 style.css 。

我已經有子主題了嗎?

所以首先我們需要看看您的主題是什麼,是父主題還是子主題。如果它是父主題,那麼您應該建立一個子主題,將函式檔案新增到該子主題並將您的更改放在那裡。如果您更改父主題中的任何檔案,您可能會在更新或升級時丟失更改。所以您不想改變父主題檔案。

您的 wordpress 主題

首先,您的 wordpress 安裝將使用 “主題”——這是一組檔案,用於設計您的網站(外觀)並新增一些功能(如何執行)。

您可能正在使用 “預設主題”20 、 21 、 21 、 23 和 24 之一。這些主題由 wordpress 團隊編寫和維護,所有 wordpress 和 bbpress 程式碼都針對這些主題進行測試以確保其正常工作。這就是為什麼經常要求您使用 “預設主題” 測試 bbpress 問題的原因,作為調查過程的一部分。

或者,您可能正在使用 “免費主題” 。其中許多都可以在 https://wordpress.org/themes/ 上找到  。

第三,您可能正在使用付費主題。這些往往更復雜,並提供很多好東西,但與 bbpress 的整合可能更復雜。如果 bbpress 對您的網站很重要,則值得在購買之前檢查您的付費主題是否積極支援 bbpress 。大多數主題可以透過一些調整與 bbPress 一起使用,但最初讓它執行並且看起來很棒真的很令人沮喪。

最後,您可能正在使用子主題。很簡單,這是一個主題,它使用上述之一(預設主題、免費主題或購買的主題)作為基礎,然後進行了更改。如果您花錢請人為您建立或定製一個站點,那麼它很有可能是一個子主題。

那麼您怎麼知道您在使用哪個?

最快的方法是進入

儀表盤> 外觀> 主題

您將看到站點上安裝的主題列表,您將看到列出的第一個主題是 “活動的”,這就是您的站點正在使用的主題。

如果您將滑鼠懸停在活動主題上,它將顯示 “主題詳細資訊”,如果您單擊它,您將獲得有關該主題的一些資訊。

如果它是由 “wordpress 團隊” 提供的,那麼您就會知道它是預設主題。否則進入 https://wordpress.org/themes/並搜尋它。如果它在那裡,那麼它是一個免費的主題。最後,如果您在 google 上搜尋主題名稱,您應該找到一個賣家,或者至少提供一些支援細節,告訴您其他人已經編寫了這個主題。

如果其中任何一個顯示,那麼您的父主題在其他地方得到支援,並且它們可能會發布更新,因此如果您更改其中的任何檔案,您可能會在更新或升級時丟失更改。所以您不想改變這些檔案。

如果您無法透過上述任何一種方法找到您的主題,或者您知道有人專門為您更改了主題,那麼很可能這是一個子主題,因此不應由任何外部人員更新,因此您應該能夠無所顧慮地進行更改。

所以最後的測試是檢查您的主題是否已經是子主題,我們將準備繼續。所以現在您需要能夠進入 FTP,並將檔案傳輸到您的 PC,以便您可以檢視它以閱讀標題。

什麼是 FTP 以及如何訪問它?

要訪問您的檔案,您需要一個 FTP 客戶端。一些主機提供商在其管理範圍內進行處理,如有疑問,請諮詢您的主機提供商。

否則,您需要將程式載入到您的 PC 上。有幾種可用,但最受歡迎的一種稱為 “Filezilla” 。

要了解如何下載此程式並在您的 PC 上使用它,以下影片將有所幫助

http://www.youtube.com/watch?v=Wtqq1Mn1ltA

還有很多其他教程 – 只需谷歌 “filezilla 教程影片”

其他 FTP 程式也可用,只需谷歌 “FTP 客戶端”

要訪問您的網路檔案,您需要三項資訊:

  • 主持人
  • 使用者名稱
  • 密碼

注意:FTP 使用者名稱和密碼與您的 wordpress 登入名/wp-admin/admin 詳細資訊完全分開。

您的主機提供商通常會在您的管理區域中列出它,因此只需四處尋找 FTP,如果有疑問,請聯絡您的主機提供商。

然後跟著教程

https://make.wordpress.org/training/handbook/theme-school/child-themes/

或檢視影片

https://www.youtube.com/watch?v=yDPbCV5_2Cw

如果您的主題如步驟 2 所示匯入了另一個主題,那麼您已經有了一個子主題。

如果沒有,上面的教程將向您展示如何製作一個。

最後,您將擁有一個帶有 style.css 檔案的子主題

使用記事本++更改程式碼

由於您將要建立或更改檔案,因此您需要有人來執行此操作。可以使用普通的記事本,但大多數情況下您將無法閱讀,並且您會弄得一團糟。

所以從 http://notepad-plus-plus.org/下載 Notepad++

它易於使用,而且更好!

將函式檔案新增到您的子主題

如果您已經有一個子主題,那麼您可能已經有一個函式檔案,只需在您的主題資料夾中查詢一個名為 functions.php 的檔案即可。

如果不是,您將需要建立一個函式檔案。

只需開啟記事本++,建立一個新檔案並放入

 <?php

在開始時。現在將其儲存為 functions.php 並將其上傳到您的主題。就是這樣。您現在有了一個函式檔案!

將程式碼新增到函式檔案

好的,現在當您看到 “將其新增到您的函式檔案” 時,您就會知道您需要使用 FTP 將當前的函式檔案下載到您的 PC 上。然後使用記事本++將程式碼複製到函式檔案的末尾。然後使用 FTP 將修改後的檔案上傳回您的站點以覆蓋舊檔案。

將樣式新增到 style.css

由於您現在將 style.css 作為子主題的組成部分,您可以向該檔案新增任何更改。

 

 

就是這樣……!!