{"id":33972,"date":"2019-03-04T10:42:05","date_gmt":"2019-03-04T10:42:05","guid":{"rendered":"http:\/\/getshortcodes.com\/?post_type=docs&#038;p=33972"},"modified":"2023-02-20T14:33:41","modified_gmt":"2023-02-20T14:33:41","slug":"post-data","status":"publish","type":"docs","link":"https:\/\/getshortcodes.com\/docs\/post-data\/","title":{"rendered":"Post data"},"content":{"rendered":"<div class=\"block-demo block-demo-default\">\n\t<div class=\"block-demo-viewport\">\n\t\t<p>Post data<\/p>\n\t<\/div>\n\t<div class=\"block-demo-source\">\n\t\t<pre contenteditable=\"true\"><\/pre>\n\t<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"description\">Description<\/h2>\n\n\n\n<p>This shortcode allows to display various post fields, including post title, post content, modified date etc.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"options\">Options<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><th>Option name<\/th><th>Possible values<\/th><th>Default value<\/th><\/tr><tr><td><strong>field<\/strong><br>Post data field name<\/td><td>ID (Post ID)<br>post_author (Post author)<br>post_date (Post date)<br>post_date_gmt (Post date GMT)<br>post_content (Post content (Raw))<br>the_content (Post content (Filtered))<br>post_title (Post title)<br>post_excerpt (Post excerpt)<br>post_status (Post status)<br>comment_status (Comment status)<br>ping_status (Ping status)<br>post_name (Post name)<br>post_modified (Post modified)<br>post_modified_gmt (Post modified GMT)<br>post_parent (Post parent)<br>guid (GUID)<br>menu_order (Menu order)<br>post_type (Post type)<br>post_mime_type (Post mime type)<br>comment_count (Comment count)<\/td><td>post_title<\/td><\/tr><tr><td><strong>default<\/strong><br>This text will be shown if data is not found<\/td><td>Any text value<\/td><td><em>\u2013 none \u2013<\/em><\/td><\/tr><tr><td><strong>before<\/strong><br>This content will be shown before the value<\/td><td>Any text value<\/td><td><em>\u2013 none \u2013<\/em><\/td><\/tr><tr><td><strong>after<\/strong><br>This content will be shown after the value<\/td><td>Any text value<\/td><td><em>\u2013 none \u2013<\/em><\/td><\/tr><tr><td><strong>post_id<\/strong><br>You can specify custom post ID. Post slug is also allowed. Leave this field empty to use ID of the current post. Current post ID may not work in Live Preview mode<\/td><td>Any text value<\/td><td><em>\u2013 none \u2013<\/em><\/td><\/tr><tr><td><strong>post_type<\/strong><br>Post type of the post you want to display the data from<\/td><td>Post type slug(s) separated by comma(s)<\/td><td>post<\/td><\/tr><tr><td><strong>filter<\/strong><br>You can apply custom filter to the retrieved value. Enter here function name. Your function must accept one argument and return modified value. Name of your function must include word filter. Example function: <br><code>function my_custom_filter( $value ) {return 'Value is: ' . $value;}<\/code><\/td><td>Any text value<\/td><td><em>\u2013 none \u2013<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"post-field-is-not-allowed\">Post: field is not allowed<\/h2>\n\n\n\n<p>Since version 5.12.8 the plugin only allows you to display a set of specific post fields (see the Options table above for the full list). Any fields that are not whitelisted will trigger the &#8220;field is not allowed&#8221; error.<\/p>\n\n\n\n<p>This mechanism was introduced to improve the plugin security, since the shortcode can be used, for example, by a contributor user to access sensitive information about any post of the site.<\/p>\n\n\n\n<p>The list of allowed fields can be extended with the <code>su\/config\/post_fields<\/code> filter. To whitelist a specific field, add the code below to the end of the functions.php file of active theme. Please be careful, since the added field can be used by other writers on your site.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter( 'su\/config\/post_fields', function( $fields ) {\n\t\/\/ The field 'post_field' will be whitelisted\n\t\/\/ and the 'Post Field' string will be used in the Insert Shortcode window\n\t$fields&#091;'post_field'] = 'Post Field';\n\treturn $fields;\n} );<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized is-style-outline\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2023\/02\/Screenshot-mq4jK4j2@2x-1024x762.png\" alt=\"\" class=\"wp-image-38661\" width=\"512\" height=\"381\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2023\/02\/Screenshot-mq4jK4j2@2x-1024x762.png 1024w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2023\/02\/Screenshot-mq4jK4j2@2x-512x381.png 512w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2023\/02\/Screenshot-mq4jK4j2@2x-128x95.png 128w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2023\/02\/Screenshot-mq4jK4j2@2x-768x572.png 768w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2023\/02\/Screenshot-mq4jK4j2@2x-80x60.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2023\/02\/Screenshot-mq4jK4j2@2x-24x18.png 24w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2023\/02\/Screenshot-mq4jK4j2@2x.png 1080w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/figure>\n","protected":false},"featured_media":36658,"template":"","docs_category":[21],"class_list":["post-33972","docs","type-docs","status-publish","has-post-thumbnail","hentry","docs_category-shortcodes"],"_links":{"self":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs\/33972","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/types\/docs"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/media\/36658"}],"wp:attachment":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/media?parent=33972"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs_category?post=33972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}