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

首頁外掛目錄 › Body Class By URL Parameter
WordPress 外掛 Body Class By URL Parameter 的封面圖片
50+
安裝啟用
★★★★★
5/5 分(1 則評價)
143 天前
最後更新
問題解決
WordPress 4.6+ PHP 5.6+ v0.0.2 上架:2021-10-29

內容簡介

此外掛會根據 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。其他使用者將無法利用此外掛。

外掛標籤

開發者團隊

⬇ 下載最新版 (v0.0.2) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Body Class By URL Parameter」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

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

延伸相關外掛

文章
Filter
Mastodon