{"id":2137,"date":"2023-12-10T15:00:14","date_gmt":"2023-12-10T15:00:14","guid":{"rendered":"https:\/\/wpshortcode.org\/?p=2137"},"modified":"2023-12-10T15:00:14","modified_gmt":"2023-12-10T15:00:14","slug":"display-post-types","status":"publish","type":"post","link":"https:\/\/wpshortcode.org\/display-post-types\/","title":{"rendered":"Display Post Types Shortcode"},"content":{"rendered":"\n        \n        <p class=\"wp-block-paragraph\">Below, you&#8217;ll find a detailed guide on how to add the <strong>Display Post Types Shortcode<\/strong> to your WordPress website, including its <strong>parameters<\/strong>, <strong>examples<\/strong>, and <strong>PHP function code<\/strong>. Additionally, we&#8217;ll assist you with common issues that might cause the Display Post Types Plugin shortcode not to show or not to work correctly.<\/p>\n        \n\n        \n        <p class=\"wp-block-paragraph\">Before starting, here is an overview of the Display Post Types Plugin and the shortcodes it provides:<\/p>\n        \n        \n        <p>            <div class=\"plugin-info-box\">\n        <div class=\"top-main\">\n            <!-- SVG Image -->\n            <div class=\"plugin-image\">\n                <img decoding=\"async\" src=\"https:\/\/ps.w.org\/display-post-types\/assets\/icon-256x256.png?rev=2144506\" alt=\"Plugin Icon\" \/>\n            <\/div>\n            \n            <div class=\"plugin-descriptive-part\">\n                <!-- Plugin Name with Link -->\n\n                    <a class=\"plugin-title\" href=\"https:\/\/wordpress.org\/plugins\/display-post-types\" target=\"_blank\" rel=\"noopener\">\n                        Display Post Types &#8211; Post Grid, post list and post sliders                    <\/a>\n\n\n                <!-- Plugin Description -->\n                <p class=\"plugin-description\">\n                    &quot;Display Post Types is a versatile WordPress plugin that organizes your content into grids, lists, and sliders. It simplifies post navigation and enhances visual appeal for your site&#039;s visitors.&quot;                <\/p>\n            <\/div>\n        <\/div>\n\n        <!-- Rating and Additional Info -->\n        <div class=\"plugin-meta\">\n            <span class=\"plugin-rating\">\n                <span class='stars'>\u2605\u2605\u2605\u2605\u2605<\/span> (11)\n            <\/span>\n            <span class=\"plugin-active-installs\">\n                <strong>Active Installs<\/strong>: 3000+\n            <\/span>\n            <span class=\"plugin-tested\">\n                <strong>Tested with<\/strong>: 6.3.2            <\/span>\n            <span class=\"plugin-php-version\">\n                <strong>PHP Version<\/strong>: 7.2            <\/span>\n        <\/div>\n\n        <!-- List of Included Shortcodes -->\n        <div class=\"plugin-shortcodes\">\n            <strong>Included Shortcodes:<\/strong>\n            <ul>\n                <li>[dpt]<\/li>            <\/ul>\n        <\/div>\n    <\/div>\n    <\/p>\n\n            <div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n            \n            \n            \n            <h2 class=\"wp-block-heading\">Display Post Types [dpt] Shortcode<\/h2>\n            \n            \n            \n            <p class=\"wp-block-paragraph\">The Display Post Types shortcode is a powerful tool in WordPress that allows you to customize the display of your posts. \n\n\n\nThis shortcode fetches posts based on specified criteria like post IDs, page IDs, or taxonomy terms. It supports various display styles and parameters, enabling you to tailor the output to your needs. The results can be ordered, filtered, and styled according to the applied attributes. \n\nThe shortcode&#8217;s flexibility makes it a valuable asset for any WordPress site, enhancing content presentation and user experience.<\/p>\n            \n\n            \n            <p class=\"wp-block-paragraph\"><strong>Shortcode<\/strong>: <code>[dpt]<\/code><\/p>\n            \n            \n            \n            <div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n            \n                <h3 class=\"wp-block-heading\">Parameters<\/h3>\n                \n                \n                \n                <p class=\"wp-block-paragraph\">Here is a list of all possible dpt shortcode parameters and attributes:<\/p>\n                \n                \n                <ul>\n<li><code>post_type<\/code> &#8211; Defines the type of post to display.<\/li>\n<li><code>taxonomy<\/code> &#8211; Specifies the taxonomy for filtering the posts.<\/li>\n<li><code>terms<\/code> &#8211; Lists the taxonomy terms for filtering the posts.<\/li>\n<li><code>relation<\/code> &#8211; Sets the relationship between multiple taxonomies.<\/li>\n<li><code>post_ids<\/code> &#8211; Identifies specific posts to be displayed.<\/li>\n<li><code>pages<\/code> &#8211; Identifies specific pages to be displayed.<\/li>\n<li><code>number<\/code> &#8211; Sets the number of posts\/pages to display.<\/li>\n<li><code>orderby<\/code> &#8211; Determines the order of displayed posts\/pages.<\/li>\n<li><code>order<\/code> &#8211; Sets the direction of ordering (ascending or descending).<\/li>\n<li><code>styles<\/code> &#8211; Defines the styling of the displayed posts\/pages.<\/li>\n<li><code>style_sup<\/code> &#8211; Supplements the main style definition.<\/li>\n<li><code>image_crop<\/code> &#8211; Determines the cropping position of the image.<\/li>\n<li><code>img_aspect<\/code> &#8211; Sets the aspect ratio of the image.<\/li>\n<li><code>img_align<\/code> &#8211; Aligns the image in the post\/page.<\/li>\n<li><code>br_radius<\/code> &#8211; Sets the border radius of the image.<\/li>\n<li><code>col_narr<\/code> &#8211; Defines the column arrangement.<\/li>\n<li><code>pl_holder<\/code> &#8211; Decides if placeholder text will be displayed.<\/li>\n<li><code>show_pgnation<\/code> &#8211; Decides if pagination will be displayed.<\/li>\n<li><code>text_align<\/code> &#8211; Aligns the text in the post\/page.<\/li>\n<li><code>v_gutter<\/code> &#8211; Sets the vertical space between posts\/pages.<\/li>\n<li><code>h_gutter<\/code> &#8211; Sets the horizontal space between posts\/pages.<\/li>\n<li><code>e_length<\/code> &#8211; Determines the length of the excerpt.<\/li>\n<li><code>e_teaser<\/code> &#8211; Sets the teaser text for the excerpt.<\/li>\n<li><code>classes<\/code> &#8211; Adds additional CSS classes to the post\/page.<\/li>\n<li><code>offset<\/code> &#8211; Skips a certain number of posts\/pages.<\/li>\n<li><code>autotime<\/code> &#8211; Sets the automatic refresh time for the posts\/pages.<\/li>\n<\/ul>\n    \n                \n                <div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n                \n                <h3 class=\"wp-block-heading\">Examples and Usage<\/h3>\n                \n \n            <p><strong>Basic example<\/strong> &#8211; The following shortcode displays posts using default parameters.<\/p>\n\n<pre class=\"wp-block-code\"><code>[dpt \/]<\/code><\/pre>\n\n\n<p><strong>Advanced examples<\/strong><\/p>\n\n<p>Displaying posts from a specific category (terms) and limiting the number of displayed posts.<\/p>\n\n<pre class=\"wp-block-code\"><code>[dpt terms=\"category1, category2\" number=5 \/]<\/code><\/pre>\n\n\n<p>Displaying specific posts by their IDs and ordering them by title in ascending order.<\/p>\n\n<pre class=\"wp-block-code\"><code>[dpt post_ids=\"1,2,3\" orderby=\"title\" order=\"ASC\" \/]<\/code><\/pre>\n\n\n<p>Displaying posts from a specific post type and applying a custom style.<\/p>\n\n<pre class=\"wp-block-code\"><code>[dpt post_type=\"custom_post_type\" styles=\"custom_style\" \/]<\/code><\/pre>\n\n\n<p>Displaying pages by their IDs and excluding the page set as &#8216;page for posts&#8217; in WordPress settings.<\/p>\n\n<pre class=\"wp-block-code\"><code>[dpt pages=\"10,20,30\" \/]<\/code><\/pre>\n\n\n<p>Displaying posts with pagination and alignment of the text to the center.<\/p>\n\n<pre class=\"wp-block-code\"><code>[dpt show_pgnation=\"yes\" text_align=\"center\" \/]<\/code><\/pre>\n\n\n            \n            <div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n            \n            <h3 class=\"wp-block-heading\">PHP Function Code<\/h3>\n            \n            \n            \n            <p class=\"wp-block-paragraph\">In case you have difficulties debugging what causing issues with <code>[dpt]<\/code> shortcode, check below the related PHP functions code.<\/p>\n            \n                    \n                    <p class=\"wp-block-paragraph\"><strong>Shortcode line<\/strong>:<\/p>\n                    \n        \n                    \n                    <pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">add_shortcode( 'dpt', array( $inst, 'render' ) );<\/code><\/pre>\n                    \n                    \n                    <p class=\"wp-block-paragraph\"><strong>Shortcode PHP function<\/strong>:<\/p>\n                    \n            \n                    <div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; light: false; title: ; toolbar: true; notranslate\" title=\"\">\n                    function render( $atts, $dpt_content = null ) {\n\n\t\t$defaults = Get_Fn::defaults();\n\t\t$atts     = shortcode_atts( $defaults, $atts, &#039;dpt&#039; );\n\n\t\t$terms = array();\n\t\tif ( ! empty( $atts&#91;&#039;terms&#039;] ) ) {\n\t\t\t$terms = explode( &#039;,&#039;, $atts&#91;&#039;terms&#039;] );\n\t\t\t$terms = array_map( &#039;trim&#039;, $terms );\n\t\t}\n\n\t\t$ids = array();\n\t\tif ( ! empty( $atts&#91;&#039;post_ids&#039;] ) ) {\n\t\t\t$ids = explode( &#039;,&#039;, $atts&#91;&#039;post_ids&#039;] );\n\t\t\t$ids = array_map( &#039;trim&#039;, $ids );\n\t\t}\n\n\t\t$pages = array();\n\t\tif ( ! empty( $atts&#91;&#039;pages&#039;] ) ) {\n\t\t\t$pages = explode( &#039;,&#039;, $atts&#91;&#039;pages&#039;] );\n\t\t\t$pages = array_map( &#039;trim&#039;, $ids );\n\t\t}\n\n\t\t\/\/ Check if all pages IDs are valid.\n\t\tif ( &#039;page&#039; === $atts&#91;&#039;post_type&#039;] &amp;&amp; ! empty( $pages ) ) {\n\t\t\t\/\/ Get list of all pages.\n\t\t\t$all_pages        = get_all_page_ids();\n\t\t\t$all_pages        = explode( &#039;,&#039;, $all_pages );\n\t\t\t$valid_pages      = array_diff( $all_pages, array( get_option( &#039;page_for_posts&#039; ) ) );\n\t\t\t$pages            = array_intersect( $pages, $valid_pages );\n\t\t\t$atts&#91;&#039;taxonomy&#039;] = array();\n\t\t}\n\n\t\t\/**\n\t\t * DPT display params from shortcode.\n\t\t *\n\t\t * @since 1.8.0\n\t\t *\/\n\t\t$display_args = apply_filters(\n\t\t\t&#039;dpt_shcode_display&#039;,\n\t\t\tarray(\n\t\t\t\t&#039;post_type&#039;     =&gt; $atts&#91;&#039;post_type&#039;],\n\t\t\t\t&#039;taxonomy&#039;      =&gt; $atts&#91;&#039;taxonomy&#039;],\n\t\t\t\t&#039;terms&#039;         =&gt; $terms,\n\t\t\t\t&#039;relation&#039;      =&gt; $atts&#91;&#039;relation&#039;],\n\t\t\t\t&#039;post_ids&#039;      =&gt; $ids,\n\t\t\t\t&#039;pages&#039;         =&gt; $pages,\n\t\t\t\t&#039;number&#039;        =&gt; $atts&#91;&#039;number&#039;],\n\t\t\t\t&#039;orderby&#039;       =&gt; $atts&#91;&#039;orderby&#039;],\n\t\t\t\t&#039;order&#039;         =&gt; $atts&#91;&#039;order&#039;],\n\t\t\t\t&#039;styles&#039;        =&gt; $atts&#91;&#039;styles&#039;],\n\t\t\t\t&#039;style_sup&#039;     =&gt; $atts&#91;&#039;style_sup&#039;],\n\t\t\t\t&#039;image_crop&#039;    =&gt; isset( $atts&#91;&#039;img_croppos&#039;] ) ? $atts&#91;&#039;img_croppos&#039;] : &#039;centercrop&#039;,\n\t\t\t\t&#039;img_aspect&#039;    =&gt; $atts&#91;&#039;img_aspect&#039;],\n\t\t\t\t&#039;img_align&#039;     =&gt; $atts&#91;&#039;img_align&#039;],\n\t\t\t\t&#039;br_radius&#039;     =&gt; $atts&#91;&#039;br_radius&#039;],\n\t\t\t\t&#039;col_narr&#039;      =&gt; $atts&#91;&#039;col_narr&#039;],\n\t\t\t\t&#039;pl_holder&#039;     =&gt; ( &#039;false&#039; === $atts&#91;&#039;pl_holder&#039;] || ! $atts&#91;&#039;pl_holder&#039;] ) ? &#039;&#039; : &#039;yes&#039;,\n\t\t\t\t&#039;show_pgnation&#039; =&gt; ( &#039;false&#039; === $atts&#91;&#039;show_pgnation&#039;] || ! $atts&#91;&#039;show_pgnation&#039;] ) ? &#039;&#039; : &#039;yes&#039;,\n\t\t\t\t&#039;text_align&#039;    =&gt; $atts&#91;&#039;text_align&#039;],\n\t\t\t\t&#039;v_gutter&#039;      =&gt; $atts&#91;&#039;v_gutter&#039;],\n\t\t\t\t&#039;h_gutter&#039;      =&gt; $atts&#91;&#039;h_gutter&#039;],\n\t\t\t\t&#039;e_length&#039;      =&gt; $atts&#91;&#039;e_length&#039;],\n\t\t\t\t&#039;e_teaser&#039;      =&gt; $atts&#91;&#039;e_teaser&#039;],\n\t\t\t\t&#039;classes&#039;       =&gt; $atts&#91;&#039;classes&#039;],\n\t\t\t\t&#039;offset&#039;        =&gt; $atts&#91;&#039;offset&#039;],\n\t\t\t\t&#039;autotime&#039;      =&gt; $atts&#91;&#039;autotime&#039;],\n\t\t\t),\n\t\t\t$atts\n\t\t);\n\n\t\tob_start();\n\t\tDisplay::init( $display_args );\n\t\t$content = ob_get_clean();\n\t\treturn $content;\n\t}\n                    <\/pre><\/div>\n                    \n                    <p class=\"wp-block-paragraph\"><strong>Code file location<\/strong>:<\/p>\n                    \n                    \n                    \n                    <pre class=\"wp-block-code\"><code>display-post-types\/display-post-types\/backend\/inc\/class-shortcode.php<\/code><\/pre>\n                    \n        <div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n        \n        \n        \n        <h2 class=\"wp-block-heading\">Conclusion<\/h2>\n        \n        \n        \n        <p class=\"wp-block-paragraph\">Now that you&#8217;ve learned how to embed the <strong>Display Post Types Plugin shortcode<\/strong>, understood the parameters, and seen code examples, it&#8217;s easy to use and debug any issue that might cause it to &#8216;not work&#8217;. If you still have difficulties with it, don&#8217;t hesitate to leave a comment below.<\/p>\n        ","protected":false},"excerpt":{"rendered":"<p>Below, you&#8217;ll find a detailed guide on how to add the Display Post Types Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we&#8217;ll assist you with common issues that might cause the Display Post Types Plugin shortcode not to show or not to work correctly. Before starting, here is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"name":"Display Post Types &#8211; Post Grid, post list and post sliders","slug":"","version":"2.3.0","author":"<a href=\"https:\/\/vedathemes.com\/display-post-types\/\">vedathemes<\/a>","icons":"https:\/\/ps.w.org\/display-post-types\/assets\/icon-256x256.png?rev=2144506","plugin_tags":"{\"display-posts\":\"display posts\",\"post-grid\":\"post grid\",\"post-masonry\":\"post masonry\",\"post-slider\":\"post slider\",\"show-posts\":\"show posts\"}","author_profile":"https:\/\/profiles.wordpress.org\/vedathemes\/","requires":"5.4","tested":"6.3.2","requires_php":"7.2","rating":100,"num_ratings":11,"active_installs":3000,"downloaded":36137,"last_updated":"2023-10-16 11:21am GMT","added":"2019-08-23","homepage":"","short_description":"Display list of posts, pages or any custom post types anywhere using block and widget. Show as grid, list or posts slider.","description":"\"Display Post Types is a versatile WordPress plugin that organizes your content into grids, lists, and sliders. It simplifies post navigation and enhances visual appeal for your site's visitors.\"","shortcodes":"[\"dpt\"]","footnotes":""},"categories":[1],"tags":[],"class_list":["post-2137","post","type-post","status-publish","format-standard","hentry","category-plugins"],"_links":{"self":[{"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts\/2137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/comments?post=2137"}],"version-history":[{"count":1,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts\/2137\/revisions"}],"predecessor-version":[{"id":2643,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts\/2137\/revisions\/2643"}],"wp:attachment":[{"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/media?parent=2137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/categories?post=2137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/tags?post=2137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}