plugin-icon

Get Post Content Shortcode

This plugin provides a shortcode to get the content of a post based on ID number.
評価機能
5
最終更新日時
April 20, 2016
バージョン
0.4.0
有効インストール数
100
Get Post Content Shortcode

This plugin provides a shortcode to get the content of a post based on ID number. By default, the content will be passed through wpautop() and do_shortcode() unless you tell it not to by using attributes or filters as shown below.

[post-content id="42"]

This gets the content of post 42.

[post-content id="42" autop="false"]

This gets the content of post 42 and does not call wpautop on the content.

[post-content id="42" shortcode="false"]

This gets the content of post 42 and does not call do_shortcode on the content.

[post-content id="42" autop="false" shortcode="false"]

This gets the content of post 42 and does not call wpautop or do_shortcode on the content.

[post-content id="42" status="publish,future"]

This gets the content of post 42 only if the post_status is “publish” or “future”.

[post-content id="42" field="excerpt"]

This gets the excerpt of post 42.

Note: The containing post may still have wpautop called on it’s content.

特性

  1. id – integer

    The post ID

  2. autop – boolean – default: true

    The following values equal true: true, 1, yes. All other values equal false.

  3. shortcode – boolean – default: true

    The following values equal true: true, 1, yes. All other values equal false.

  4. status – text – default: publish

    Any default or custom WordPress status value (publish, draft, future, etc.).

    The default value will be used if the status is not registered with WordPress.

  5. field – text – default: post_content

    The name of the database column you want to retrieve.

    This default value will be used if the column name is not in the array of allowed field names.

フィルター

You can modify the fields that are allowed to be retrieved with this filter.

add_filter('post-content-allowed-fields', function($allowed_fields) { // Do your filtering here. return $allowed_fields; });

You can specify the default shortcode attribute values.

add_filter('post-content-default-attributes', function ($default_attributes) { // Your code here. return $default_attributes; });

You can filter attributes per shortcode usage

add_filter('shortcode_atts_post-content', function ($out, $pairs, $attributes) { // Your code here. return $out; }, 10, 3);
無料Creator プランを利用中
インストールすることで、WordPress.com の利用規約サードパーティ製プラグインの規約に同意したとみなされます。
有効インストール数
100
最大テスト回数
4.5.0
このプラグインをダウンロードして、インストール型 WordPress のインストールに使用できます。