{"id":29602,"date":"2014-05-20T14:25:24","date_gmt":"2014-05-20T14:25:24","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/get-post-content-shortcode\/"},"modified":"2016-04-20T04:45:47","modified_gmt":"2016-04-20T04:45:47","slug":"get-post-content-shortcode","status":"closed","type":"plugin","link":"https:\/\/wordpress.org\/plugins\/get-post-content-shortcode\/","author":6822165,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"0.4.0","stable_tag":"0.4.0","tested":"4.5.0","requires":"3.6.0","requires_php":"","requires_plugins":"","header_name":"Get Post Content Shortcode","header_author":"Eric King","header_description":"","assets_banners_color":"647b7e","last_updated":"2016-04-20 04:45:47","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"http:\/\/phplug.in\/","header_author_uri":"http:\/\/webdeveric.com\/","rating":5,"author_block_rating":0,"active_installs":100,"downloads":3666,"num_ratings":7,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":"7"},"assets_icons":[],"assets_banners":{"banner-1544x500.jpg":{"filename":"banner-1544x500.jpg","revision":"917966","resolution":"1544x500","location":"assets"},"banner-772x250.jpg":{"filename":"banner-772x250.jpg","revision":"917966","resolution":"772x250","location":"assets"}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["0.2","0.3.0","0.3.1","0.3.2","0.4.0"],"block_files":[],"assets_screenshots":[],"screenshots":[]},"plugin_section":[],"plugin_tags":[3468,80],"plugin_category":[43],"plugin_contributors":[84180],"plugin_business_model":[],"class_list":["post-29602","plugin","type-plugin","status-closed","hentry","plugin_tags-post-content","plugin_tags-shortcode","plugin_category-customization","plugin_contributors-webdeveric","plugin_committers-webdeveric"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/get-post-content-shortcode_647b7e.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>This plugin provides a shortcode to get the content of a post based on ID number.\nBy default, the content will be passed through <code>wpautop()<\/code> and <code>do_shortcode()<\/code> unless you tell it not to by using attributes or filters as shown below.<\/p>\n\n<h4>Examples<\/h4>\n\n<pre><code>[post-content id=\"42\"]\n<\/code><\/pre>\n\n<p>This gets the content of post 42.<\/p>\n\n<pre><code>[post-content id=\"42\" autop=\"false\"]\n<\/code><\/pre>\n\n<p>This gets the content of post 42 and does not call wpautop on the content.<\/p>\n\n<pre><code>[post-content id=\"42\" shortcode=\"false\"]\n<\/code><\/pre>\n\n<p>This gets the content of post 42 and does not call do_shortcode on the content.<\/p>\n\n<pre><code>[post-content id=\"42\" autop=\"false\" shortcode=\"false\"]\n<\/code><\/pre>\n\n<p>This gets the content of post 42 and does not call wpautop or do_shortcode on the content.<\/p>\n\n<pre><code>[post-content id=\"42\" status=\"publish,future\"]\n<\/code><\/pre>\n\n<p>This gets the content of post 42 only if the post_status is \"publish\" or \"future\".<\/p>\n\n<pre><code>[post-content id=\"42\" field=\"excerpt\"]\n<\/code><\/pre>\n\n<p>This gets the excerpt of post 42.<\/p>\n\n<p><strong>Note:<\/strong>\nThe containing post may still have wpautop called on it's content.<\/p>\n\n<h4>Attributes<\/h4>\n\n<ol>\n<li><p><strong>id<\/strong> - integer<\/p>\n\n<p>The post ID<\/p><\/li>\n<li><p><strong>autop<\/strong> - boolean - default: true<\/p>\n\n<p>The following values equal true: true, 1, yes. All other values equal false.<\/p><\/li>\n<li><p><strong>shortcode<\/strong> - boolean - default: true<\/p>\n\n<p>The following values equal true: true, 1, yes. All other values equal false.<\/p><\/li>\n<li><p><strong>status<\/strong> - text - default: publish<\/p>\n\n<p>Any default or custom WordPress status value (publish, draft, future, etc.).<\/p>\n\n<p>The default value will be used if the status is not registered with WordPress.<\/p><\/li>\n<li><p><strong>field<\/strong> - text - default: post_content<\/p>\n\n<p>The name of the database column you want to retrieve.<\/p>\n\n<p>This default value will be used if the column name is not in the array of allowed field names.<\/p><\/li>\n<\/ol>\n\n<h4>Filters<\/h4>\n\n<p><strong>You can modify the fields that are allowed to be retrieved with this filter.<\/strong><\/p>\n\n<pre><code>add_filter('post-content-allowed-fields', function($allowed_fields) {\n    \/\/ Do your filtering here.\n    return $allowed_fields;\n});\n<\/code><\/pre>\n\n<p><strong>You can specify the default shortcode attribute values.<\/strong><\/p>\n\n<pre><code>add_filter('post-content-default-attributes', function ($default_attributes) {\n    \/\/ Your code here.\n    return $default_attributes;\n});\n<\/code><\/pre>\n\n<p><strong>You can filter attributes per shortcode usage<\/strong><\/p>\n\n<pre><code>add_filter('shortcode_atts_post-content', function ($out, $pairs, $attributes) {\n    \/\/ Your code here.\n    return $out;\n}, 10, 3);\n<\/code><\/pre>\n\n<!--section=installation-->\n<ol>\n<li>Upload <code>get-post-content-shortcode<\/code> folder to the <code>\/wp-content\/plugins\/<\/code> directory<\/li>\n<li>Activate the plugin through the 'Plugins' menu in WordPress<\/li>\n<li>Place <code>[post-content id=\"SOME OTHER POST ID\"]<\/code> in your content.<\/li>\n<\/ol>\n\n<!--section=changelog-->\n<h4>0.4.0<\/h4>\n\n<ul>\n<li>Added a filter to allow you to specify the default values for the shortcode attributes.<\/li>\n<\/ul>\n\n<h4>0.3.2<\/h4>\n\n<ul>\n<li>Added <code>field<\/code> attribute so you can specify what content to return.<\/li>\n<\/ul>\n\n<h4>0.3.1<\/h4>\n\n<ul>\n<li>By default, this shortcode will only get content of published posts, unless you specify the status attribute.<\/li>\n<\/ul>\n\n<h4>0.3.0<\/h4>\n\n<ul>\n<li>I updated the code to temporarily switch to the other post so that shortcodes in the other post will work as expected.<\/li>\n<\/ul>\n\n<h4>0.2.0<\/h4>\n\n<ul>\n<li>I updated the code to use the <code>get_post_field<\/code> function instead of <code>get_post<\/code>.<\/li>\n<\/ul>\n\n<h4>0.1.0<\/h4>\n\n<ul>\n<li>Initial build<\/li>\n<\/ul>","raw_excerpt":"This plugin provides a shortcode to get the content of a post based on ID number.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/29602","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=29602"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/webdeveric"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=29602"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=29602"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=29602"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=29602"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=29602"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=29602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}