[WordPress] 外掛分享: Body Class By URL Parameter

WordPress 外掛 Body Class By URL Parameter 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Body Class By URL Parameter」是 2021-10-29 上架。
  • 目前有 70 個安裝啟用數。
  • 上一次更新是 2025-04-18,距離現在已有 16 天。
  • 外掛最低要求 WordPress 4.6 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 5.6 以上。
  • 有 1 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

giuse |

外掛標籤

body class | custom CSS by URL |

內容簡介

此外掛會根據 URL 中包含的參數,在 body 中新增 CSS 類別。

對於每個 URL 查詢參數,外掛都會新增一個由[bc]-[參數名稱]-[參數值]組成的 CSS 類別。

其中,[bc] 為相同的前綴詞。

例如,如果您在 Facebook 上分享頁面 https://your-domain.com/sample-page,使用者點擊連結後會進入一個看起來像 https://your-domain.com/sample-page/?fbclid=IwAR0o12nq9Em-x1n 的頁面。

在這種情況下,外掛會在 body 中新增類別 bc-fbclid-IwAR0o12nq9Em-x1n。

然後,您可以使用該類別來自訂 CSS。

.bc-fbclid-IwAR0o12nq9Em-x1n .disable-for-facebook{
display:none !important
}

在上面的範例中,如果使用者從在 Facebook 上分享的連結進入,則隱藏所有具有 disable-for-facebook 類別的元素。

這只是個範例。您可以根據 URL 中包含的任何查詢參數創建不同的樣式。

使用此外掛需要您至少具備基本的 CSS 技能並知道該如何放置自訂 CSS。其他使用者將無法利用此外掛。

原文外掛簡介

It adds CSS classes to the body depending on the parameters included in the URL.
For each URL query argument, the plugin adds a CSS class to the body that is composed by [bc]-[paramenter name]-[parameter value].
Where [bc] is the a prefix that is always the same.
If for example you share your page https://your-domain.com/sample-page on Facebook, the user after clicking on the link will land on a page having an URL that looks like https://your-domain.com/sample-page/?fbclid=IwAR0o12nq9Em-x1n
In this case the plugin would add the class bc-fbclid-IwAR0o12nq9Em-x1n to the body.
Then you can use that class for your custom CSS.
.bc-fbclid-IwAR0o12nq9Em-x1n .disable-for-facebook{
display:none !important
}

In the example above you hide all the elements that have the class .disable-for-facebook if the users come from the link shared on Facebook.
This is just an example. You can use it to create different styles depending on whatever query arguments are included in the URL.
The use of this plugin requires that you have at least basic CSS skills and you know where to put your custom CSS. All other users will not be able to take advantage of this plugin.
0.0.2

Checked WordPress 6.4

0.0.1
*Initial release

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Body Class By URL Parameter」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


0.0.1 | 0.0.2 | trunk |

延伸相關外掛(你可能也想知道)

  • WP Browser/Platform Detection 》這個外掛程式可以很好地偵測使用的瀏覽器和平台。對於使用 WordPress 的開發人員來說,偵測瀏覽器和平台可能有些複雜。這個外掛程式會在網頁的 body 標籤中加...。
  • Add More Body Classes 》「Add More Body Classes」外掛可新增額外的類別至 body 標籤中,新增的類別包括:, , locale-[locale]:例如:對於日文站台會新增 locale-ja,預設英文站則...。

文章
Filter
Apply Filters
Mastodon