內容簡介
PHP Liquid 是一個 WordPress 外掛,允許您在樣式表和頁面/文章中添加 Liquid 標記。
從 2.0 版本開始,我甚至加入了一個方便的 GUI 介面,可讓您建立和編輯 Liquid 標記變數。
作為此外掛的一部分,您還可以使用 Liquid 建立圖像輪播。
要了解 Liquid 是什麼,請前往以下網址:
http://liquidmarkup.org/
請仔細閱讀安裝說明。如果您想在樣式表中使用 Liquid,必須在您的 header.php 中使用 liquid_stylesheet_url() 替換 bloginfo( 'stylesheet_url' )。
如果您在主題功能文件中編寫此方法:
function override_mytheme_liquid_array() {
return array('site_url' => get_option('siteurl'), "items" => array("1","2"));
}
並在您的 style.css 文件中編寫以下行:
{% for item in items %}
#banner_{{ item }} {
background: url("/images/test_{{ item }}.png");
}
{% endfor %}
您的網站實際上將呈現以下 css:
banner_1 {
background: url(“/images/test_1.png”);
}
banner_2 {
background: url(“/images/test_2.png”);
}
所以使用此外掛,您可以使用動態 css,很酷吧。
從版本 1.4 中引入 - 您現在可以在模板中編寫:
echo(parse_liquid("{{site_url}}"));
並在您的模板中呈現 Liquid 標記。
外掛標籤
開發者團隊
原文外掛簡介
PHP Liquid is a WordPress plugin that allows you to add liquid tags to your stylesheet and page/posts.
After version 2.0, I’ve even included a handy GUI interface which allows you to create and edit your liquid tag variables.
As part of this plugin, you can also create an image slider using liquid.
To find out what liquid is please go to the following url:
http://liquidmarkup.org/
Please read the install instructions carefully. You need to replace bloginfo( ‘stylesheet_url’ ) with liquid_stylesheet_url() in your header.php if you want to use liquid in your stylesheet.
If you write this method in your theme functions file:
function override_mytheme_liquid_array() {
return array(‘site_url’ => get_option(‘siteurl’), “items” => array(“1″,”2”));
}
and write the following lines in your style.css file:
{% for item in items %}
#banner_{{ item }} {
background: url("/images/test_{{ item }}.png");
}
{% endfor %}
your website will actually render the following css:
banner_1 {
background: url(“/images/test_1.png”);
}
banner_2 {
background: url(“/images/test_2.png”);
}
So with this plugin, you can use dynamic css, cool hey.
Introduced in version 1.4 – You can now write:
echo(parse_liquid(“{{site_url}}”));
into your template, and render liquid tags in your template.
