[WordPress] 外掛分享: Display Custom Fields

首頁外掛目錄 › Display Custom Fields
10+
安裝啟用
★★★★★
5/5 分(1 則評價)
4255 天前
最後更新
問題解決
WordPress 3.0+ v1.1.1 上架:2014-05-16

內容簡介

此外掛可讓您在頁面或文章上顯示自訂欄位的值。允許的值為原始文字、HTML、JavaScript、JavaScript 檔案 URL、CSS 或 CSS 檔案。

從版本 1.1.x 開始,您也可以顯示任何頁面或文章的自訂欄位,只要您有 id。

此外掛的其中一個預期用途是提供即時的程式碼,而不需編輯佈景主題。通常,程式碼,尤其是 CSS,在佈景主題更改時會丟失。這種技術將確保僅在指定的頁面上加載值,並且它們將在佈景主題和其他外掛更改時仍然存在。

您還可以使用此外掛來包含 JavaScript 片段或檔案。它們將僅在指定的文章或頁面上加載。這反過來允許僅在需要時加載腳本。

您可以使用此外掛的兩種方式:
[dcf field=”custom_field_name”]
或選擇性地,您可以
– 定義欄位值的類型。默認類型為“原始值”。
– 提供頁面或文章的 ID 編號。默認情況下,它將是當前頁面或文章的 ID。
[dcf field=”custom_field_name” type=”value_type” id=’post_or_page_id_number’]

接受的值類型為:

“原始值” – 這是默認值,您不需要指定此類型。它會按原樣輸出值。您可以在值中安全地使用 HTML 代碼。

“JS” – 使用此選項指定值實際上是 JavaScript。不要用 script 標籤包裝它。請記住,$ 在 WordPress 中不是有效的 jQuery 替代品。您應該使用“jQuery”代替。

“JSF” – 您可能需要包含 JavaScript 檔案。自訂欄位的值應為完全限定的 JavaScript 檔案 URL。

“CSS” – 使用此選項指定自訂欄位中的值為 CSS 代碼。

“CSSF” – 您可能需要包含 CSS 檔案。自訂欄位的值應為完全限定的 CSS 檔案 URL。在此,我要注意以下事項:
– 在 body 中包含 CSS 檔案非常不尋常。然而,它確實可以運作。
– 有可能出現副作用,某些元素在完全載入 CSS 檔案之前可能無法正確顯示。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.1.1) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Display Custom Fields」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

This plugin allows you to display the value of a custom field on a page or post. Permitted values are raw text, html, javascript, javascript file url, css, css file.
Since version 1.1.x it also allows you to show a custom field of any page or post, provided you have the id.
One of the intended use of this plugin is to provide just in time code without editing the theme. Often code, especially css, gets lost with theme change. This techniques will ensure the values are loaded only on the given page and they will survive changes of themes and other plugins.
You can also use this to include javascript snippets or files. They will only be loaded on the given post or page. This in turn allows for loading of scripts only where needed.
You may use the plugin in two ways:
[dcf field=”name_of_custom_field”]
or optionally you can
– define the type of the field value. By default the type is “raw”.
– provide the id number of the page or post. By default, it would be the current page/post id.
[dcf field=”name_of_custom_field” type=”value_type” id=’post_or_page_id_number’]
The accepted value types are:
“raw” – this is the default and you do not need to specify this type. It outputs the value as it is. You can use html code in the values quite safely.
“js” – use this to specify that the value is actually javascript. Do not wrap it with the script tag. Remember that $ is not a valid jQuery replacement in WordPress. You should use “jQuery” instead.
“jsf” – You may need to include a javascript file. The value of the custom field should be a fully qualified javascript file url.
“css” – use this to specify css code in the value of the custom field.
“cssf” – You may need to include a css file. The value of the custom field should be a fully qualified css file url. Here I would like to note that:
– It is highly unusual to include css files in the body. However, it does work.
– There may be a side effect that some elements may not show properly until the css file is completely loaded.

延伸相關外掛

文章
Filter
Mastodon