Title: WP Boilerplate Shortcode
Author: Mike Schinkel
Published: <strong>2010 年 3 月 28 日</strong>
Last modified: 2010 年 3 月 29 日

---

搜尋外掛

這個外掛**並未在最新的 3 個 WordPress 主要版本上進行測試**。開發者可能不再對這個
外掛進行維護或提供技術支援，並可能會與更新版本的 WordPress 產生使用上的相容性問題。

![](https://s.w.org/plugins/geopattern-icon/wp-boilerplate-shortcode.svg)

# WP Boilerplate Shortcode

 由 [Mike Schinkel](https://profiles.wordpress.org/mikeschinkel/) 開發

[下載](https://downloads.wordpress.org/plugin/wp-boilerplate-shortcode.1.0.3.zip)

 * [詳細資料](https://tw.wordpress.org/plugins/wp-boilerplate-shortcode/#description)
 * [使用者評論](https://tw.wordpress.org/plugins/wp-boilerplate-shortcode/#reviews)
 *  [安裝方式](https://tw.wordpress.org/plugins/wp-boilerplate-shortcode/#installation)
 * [開發資訊](https://tw.wordpress.org/plugins/wp-boilerplate-shortcode/#developers)

 [技術支援](https://wordpress.org/support/plugin/wp-boilerplate-shortcode/)

## 外掛說明

This plugin provides a shortcode that when inserted will display the body from a
referenced “_boilerplate_.” A boilerplate is a special post type defined by this
plugin. References can be made by title, path or ID. Below is a list of shortcode
attributes used by the boilerplate shortcode. Examples are given for hypothetical“
_Copyright_” and “_Payment Terms._” All attributes are optional except one of “_byid_“,“
_bypath_” or “_bytitle_” must be specified:

 * **bytitle**: The full case-sensitive title of the boilerplate, i.e. “_Copyright_”
   or “_Payment Terms_“
 * **bypath**: The editable lowercase path for the boilerplate, i.e. “_copyright_”
   or “_payment-terms_” (vs. “_/boilerplates/copyright/_” or “_/boilerplates/payment-
   terms/_“)
 * **byid**: Refers to the internal ID from the wp_posts table for the boilerplate
   post, i.e. 234 or 1273
 * **showtitle**: “_true_” or “_false_” (defaults to “_false_“); if “_true_” boilerplate
   content will be prefixed with the title of the boilerplate as entered in the 
   edit screen, or optionally with a “_title_” attribute you specify.
 * **title**: Use to override the displayed title of the boilerplate in specific
   cases. When “_title_” is specified “_showtitle_” is implicity set to “_true_.”
 * **titletag**: HTML element used to wrap the title when “_showtitle_” is explicity“
   _true_” or “_title_” is set (defaults to “_h3_.”)
 * **id**: The HTML “_id_” attribute applied to the div element that wraps the boilerplate
   and it’s optional title. If not specificed the div will not get have an “_id_”
   set.
 * **class**: The HTML “_class_” attribute applied to the div& element that wraps
   the boilerplate and it’s optional title (defailts to “_boilerplate_.”)

## 螢幕擷圖

[⌊Editing Boilerplates in the WordPress admin.⌉⌊Editing Boilerplates in the WordPress
admin.⌉[

Editing Boilerplates in the WordPress admin.

[⌊The example "Copyright" boilerplate with shortcode attribute callouts.⌉⌊The example"
Copyright" boilerplate with shortcode attribute callouts.⌉[

The example “_Copyright_” boilerplate with shortcode attribute callouts.

[⌊Inserting the "Copyright" shortcode into a post.⌉⌊Inserting the "Copyright" shortcode
into a post.⌉[

Inserting the “_Copyright_” shortcode into a post.

[⌊Output of the "Copyright" shortcode on the web.⌉⌊Output of the "Copyright" shortcode
on the web.⌉[

Output of the “_Copyright_” shortcode on the web.

[⌊Use of the_boilerplate() template tag.⌉⌊Use of the_boilerplate() template tag.⌉[

Use of `the_boilerplate()` template tag.

[⌊The example "Payment Terms" boilerplate for reference.⌉⌊The example "Payment Terms"
boilerplate for reference.⌉[

The example “_Payment Terms_” boilerplate for reference.

[⌊Inserting the "Payment Terms" shortcode into a post using most of the shortcode's
attributes.⌉⌊Inserting the "Payment Terms" shortcode into a post using most of the
shortcode's attributes.⌉[

Inserting the “_Payment Terms_” shortcode into a post using most of the shortcode’s
attributes.

[⌊Output of the "Payment Terms" shortcode on the web.⌉⌊Output of the "Payment Terms"
shortcode on the web.⌉[

Output of the “_Payment Terms_” shortcode on the web.

## 安裝方式

To install the WP Boilerplate Shortcode plugin do the following steps:

**Manual Installation from a Direct Download:**

 1. Download the plugin.
 2. Unzip the plugin’s .ZIP file.
 3. Create a sub directory off your WordPress site’s root named wp-content/plugins/
    wp-boilerplate-shortcode/ on your web host.
 4. Upload the plugin’s file to the sub directory just created at your web host.
 5. Login to your WordPress admin console.
 6. Select the Plugin’s “*Edit*” option which generates a listing of plugins.
 7. Activate this plugin.

**Automatic Installation from within the Admin Console:**

 1. Login to your WordPress admin console.
 2. Select “_Add New_” from the plugins menu.
 3. Search for “_wp boilerplate shortcode_.”
 4. Select the plugin and click “_Install_.”
 5. After installation is complete click “_Activate_.”

Once you’ve completed either the manual or automatic installation then you can either
use the `boilerplate` shortcode or the `the_boilerplate()` template tag. See the
[FAQ](https://wordpress.org/extend/plugins/wp-boilerplate-shortcode/faq/) for instructions
on how to use the shortcode and/or the template tag.

## 常見問題集

  Where do add/edit my boilerplates?

Look on the left sidebar in your WordPress admin after you’ve activated the plugin
for a menu called “_Boilerplates_.”

  Can you give me examples of using the shortcode?

Sure. Here are some simple examples:

 *     ```
        [boilerplate bytitle="Payment Terms"]
       ```
   
 *     ```
        [boilerplate bypath="copyright"]
       ```
   
 *     ```
        [boilerplate byid="971"]
       ```
   

Here are some more complex examples:

 *     ```
        [boilerplate bytitle="Payment Terms" showtitle="true" title="Terms for Payment" titletag="strong" id="terms"]
       ```
   
 *     ```
        [boilerplate bypath="copyright" class="boilerplate copyright"]
       ```
   

  Where do I type the shortcode?

Type the shortcode into the body of any page, of any post, or of any custom post
type where you want the boilerplate processed.

  Does this plugin provide a boilerplate template tag?

Yes:

 1.     ```
        the_boilerplate('contact-methods'); // 'contact-methods' = the path of the boilerplate.
        ```
    
 2.     ```
        the_boilerplate('Contact Methods','title'); // 'Contact Methods' = the title of the boilerplate.
        ```
    
 3.     ```
        the_boilerplate(123,'id',array('showtitle'=>'true')); // 123 = boilerplate's post ID.
        ```
    

The array parameter in example #3 can contain any [of these attributes](https://tw.wordpress.org/plugins/wp-boilerplate-shortcode/..?output_format=md)

  After Adding/Editing a Boilerplate if I click “_View_” I get an error. Why?

If you are still getting this error it’s because WordPress still hasn’t addressed
this problem.

We decided to disallow boilerplates to be seen directly via a URL and as such when
you try to view them WordPress tell you you cannot see it.

An example URL that you might see (assuming you were on the domain `example.com`
and had a boilerplate called “_Copyright_“) might be as follows:

    ```
     http://example.com/boilerplates/copyright/
    ```

_**This URL will not work**_ because boilerplates do not get a page of their own.

Hopefully WordPress will address this soon and you’ll be able to view your boilerplates
from within the admin console.

  What’s the syntax for the shortcode/template tag?

If you are into things from a technical persective it looks like this (angles <>
indicate placeholders, a vertical bar | indicates “_or_“, elipsees indicate one 
or more, parens indicate grouping, and braces {} indicate optional):

 * **Shortcode**:
 *     ```
       [boilerplate (bytitle|bypath|byid)="(||)"
          {showtitle="(true|false)"} {title=""} {titletag=""}
          {id=""} {class="}]
       ```
   

For the template tag the parens are not needed for grouping and the square brackets
indicate optional, which is what most docs use for optional, when it doesn’t conflict
with actual syntax:

 * **Template Tag**:
 *     ```
       the_boilerplate(|| [, 'path'|'title'|'id']
          [, array(['showtitle'=> 'true'|false',] ['title' => '',]
          ['titletag' => '',] ['id' => '',] ['class' => '',] ));
       ```
   

## 使用者評論

這個外掛目前沒有任何使用者評論。

## 參與者及開發者

以下人員參與了開源軟體〈WP Boilerplate Shortcode〉的開發相關工作。

參與者

 *   [ Mike Schinkel ](https://profiles.wordpress.org/mikeschinkel/)

[將〈WP Boilerplate Shortcode〉外掛本地化為台灣繁體中文版](https://translate.wordpress.org/projects/wp-plugins/wp-boilerplate-shortcode)

### 對開發相關資訊感興趣？

任何人均可[瀏覽程式碼](https://plugins.trac.wordpress.org/browser/wp-boilerplate-shortcode/)、
查看 [SVN 存放庫](https://plugins.svn.wordpress.org/wp-boilerplate-shortcode/)，
或透過 [RSS](https://plugins.trac.wordpress.org/log/wp-boilerplate-shortcode/?limit=100&mode=stop_on_copy&format=rss)
訂閱[開發記錄](https://plugins.trac.wordpress.org/log/wp-boilerplate-shortcode/)。

## 變更記錄

#### 1.0.2

 * Screenshots!

#### 1.0.1

 * Added `the_boilerplate()` template tag.
 * Restructured `readme.txt` and added FAQ items and more detailed installation 
   instructions.
 * Moved code structure to an encapsulated `WPBoilerplateShortcode` class with class
   methods instead independent functions.

#### 1.0

 * Initial release.

## 中繼資料

 *  版本 **1.0.1**
 *  最後更新 **16 年前**
 *  啟用安裝數 **10+**
 *  WordPress 版本需求 ** 3.0 或更新版本 **
 *  已測試相容的 WordPress 版本 **3.0.5**
 *  語言
 * [English (US)](https://wordpress.org/plugins/wp-boilerplate-shortcode/)
 * 標籤:
 * [boilerplate](https://tw.wordpress.org/plugins/tags/boilerplate/)[shortcode](https://tw.wordpress.org/plugins/tags/shortcode/)
 *  [進階檢視](https://tw.wordpress.org/plugins/wp-boilerplate-shortcode/advanced/)

## 評分

這個項目尚無任何評論記錄。

[Your review](https://wordpress.org/support/plugin/wp-boilerplate-shortcode/reviews/#new-post)

[查看全部使用者評論](https://wordpress.org/support/plugin/wp-boilerplate-shortcode/reviews/)

## 參與者

 *   [ Mike Schinkel ](https://profiles.wordpress.org/mikeschinkel/)

## 技術支援

使用者可在技術支援論壇提出意見反應或使用問題。

 [檢視技術支援論壇](https://wordpress.org/support/plugin/wp-boilerplate-shortcode/)

## 贊助

想要支援這個外掛的發展嗎？

 [ 贊助這個外掛 ](http://www.charitywater.org/donate/)