內容簡介
Custom CSS and JS 是一款外掛,允許您透過添加自訂欄位,將樣式表和 JavaScript 添加到任何個別文章中。CSS 和腳本都可以是內部或外部的。只要佈景主題調用 "wp_head",自訂 CSS 和 JavaScript 便可使用於顯示該文章的任何佈景主題中。
如何使用本外掛
若要使用本外掛,在文章中添加下列自訂欄位中的任何一種或多種組合。
custom_css
添加自訂 CSS 外部樣式表,請添加名稱為 custom_css 的自訂欄位,欄位值為 CSS 檔案的路徑。
cusrom_css_code
添加自訂 CSS 內部樣式表,請添加名稱為 custom_css_code 的自訂欄位,欄位值為您的 CSS 代碼(請勿包含樣式標籤)。
custom_js
添加自訂 JavaScript 外掛,請添加名稱為 custom_js 的自訂欄位,欄位值為 JavaScript 檔案的路徑。
custom_js_code
添加自訂 JavaScript 內部腳本,請添加名稱為 custom_js_code 的自訂欄位,欄位值為您的 JavaScript 代碼(請勿包含 script 標籤)。
自訂欄位順序
外部樣式和腳本顯示於內部的樣式和腳本之前。
如果您為相同的自訂欄位添加多個項目,這些項目將按照其添加順序進行顯示。
哦,但如果我不喜歡這些標籤怎麼辦?
只需編輯 custom-css-js.php 並更改在文件頂部定義的常數即可。
注意
此外掛僅適用於個別文章和頁面。不適用於列表頁面(例如目錄頁面、搜索結果等)。
外掛標籤
開發者團隊
原文外掛簡介
Custom CSS and JS allows you to add stylesheets and JavaScripts to any individual post by adding custom fields. Both CSS and scripts can be either internal or external. Since this is a plugin, the custom CSS and JavaScript are available to any theme used to display the post, as long as the themes call “wp_head”.
Using the Plugin
To use the plugin, add any combination of the following custom fields to your post.
custom_css
Add an external stylesheet by adding a custom field with the name custom_css. The value of the field should be the path to your css file.
cusrom_css_code
Add an internal stylesheet by adding a custom field with the name custom_css_code. Include your CSS code as the value. (Do not include the style tags.)
custom_js
Add an external JavaScript by adding a custom field with the name custom_js. The value of the field should be the path to your script.
custom_js_code
Add an internal JavaScript by adding a custom field with the name custom_js_code. Include your JavaScript code as the value. (Do not include the script tags.)
Custom Fields Order
The external styles and scripts are included before the internal ones.
If you include multiple entries for a given field, the entries will be included in order.
Okay, but what if I don’t like those tags?
Just edit custom-css-js.php and change the constants defined near the top of the file.
Note
This plugin only works with individual posts and pages. It does not work for list pages (e.g., the index page, search results).
