このプラグインは WordPress の最新3回のメジャーリリースに対してテストされていません。もうメンテナンスやサポートがされていないかもしれず、最新バージョンの WordPress で使用した場合は互換性の問題が発生する可能性があります。

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);

インストール

  1. Upload get-post-content-shortcode folder to the /wp-content/plugins/ directory
  2. WordPress の「プラグイン」メニューからプラグインを有効化してください
  3. Place [post-content id="SOME OTHER POST ID"] in your content.

評価

2017年1月12日
This is the only one that passes through both of wpautop() and do_shortcode() so shortcodes in the Post are processed. It's perfect for what I want to do. I use several instances of the shortcode on a page to pull together content from several posts, a bit like a content management system. So thank you for this! My small issue was that the post ID in the shortcode is not descriptive, as the slug would be, which is supported by some other post-content plugins. My workround is to add an unsupported attribute to the shortcode like desc="post description" which happily makes no difference to the processing. This workround completely satisfies my need.
2016年9月3日
The only one that works with version 4.4.2 and Eric was really helpful at providing me with a solution for formatting dates. See: https://github.com/webdeveric/date-format-shortcode
2016年9月3日
I have tried numerous plugins to show the content of a specific post in a lightbox – this is the only one that actually works. I use it with Lightbox Plus Colorbox. I am VERY happy right now, thank you very much!
2016年9月3日
I tried other plugins and didn't worked, but this one work like a charm! I recommend!
7件のレビューをすべて表示

貢献者と開発者

Get Post Content Shortcode はオープンソースソフトウェアです。以下の人々がこのプラグインに貢献しています。

貢献者

“Get Post Content Shortcode” をあなたの言語に翻訳しましょう。

開発に興味がありますか ?

コードを閲覧するか、SVN リポジトリをチェックするか、開発ログRSS で購読してみてください。

変更履歴

0.4.0

  • Added a filter to allow you to specify the default values for the shortcode attributes.

0.3.2

  • Added field attribute so you can specify what content to return.

0.3.1

  • By default, this shortcode will only get content of published posts, unless you specify the status attribute.

0.3.0

  • I updated the code to temporarily switch to the other post so that shortcodes in the other post will work as expected.

0.2.0

  • I updated the code to use the get_post_field function instead of get_post.

0.1.0

  • Initial build