Этот плагин не тестировался с последними 3 основными выпусками WordPress. Скорее всего, он уже не поддерживается и может быть несовместим с текущими версиями 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.
Аттрибуты
-
id — integer
The post ID
-
autop — boolean — default: true
The following values equal true: true, 1, yes. All other values equal false.
-
shortcode — boolean — default: true
The following values equal true: true, 1, yes. All other values equal false.
-
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.
-
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);
Установка
- Upload
get-post-content-shortcode
folder to the/wp-content/plugins/
directory - Активируйте плагин используя меню ‘Плагины’ в WordPress
- Place
[post-content id="SOME OTHER POST ID"]
in your content.
Отзывы
Участники и разработчики
«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 ofget_post
.
0.1.0
- Initial build