{"id":33821,"date":"2019-03-01T10:50:37","date_gmt":"2019-03-01T10:50:37","guid":{"rendered":"http:\/\/getshortcodes.com\/?post_type=docs&#038;p=33821"},"modified":"2023-02-09T08:55:27","modified_gmt":"2023-02-09T08:55:27","slug":"posts","status":"publish","type":"docs","link":"https:\/\/getshortcodes.com\/docs\/posts\/","title":{"rendered":"Posts"},"content":{"rendered":"<div class=\"block-demo block-demo-default\">\n\t<div class=\"block-demo-viewport\">\n\t\t<div class=\"su-posts su-posts-teaser-loop \">\n<div id=\"su-post-33955\" class=\"su-post \">\n\t\t\t\t\t\t\t\t\t<a class=\"su-post-thumbnail\" href=\"https:\/\/getshortcodes.com\/docs\/rss-feed\/\"><img loading=\"lazy\" decoding=\"async\" width=\"120\" height=\"120\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2020\/10\/Feed.png\" class=\"attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2020\/10\/Feed.png 120w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2020\/10\/Feed-80x80.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2020\/10\/Feed-24x24.png 24w\" sizes=\"auto, (max-width: 120px) 100vw, 120px\" \/><\/a><\/p>\n<h2 class=\"su-post-title\"><a href=\"https:\/\/getshortcodes.com\/docs\/rss-feed\/\">RSS Feed<\/a><\/h2>\n<\/p><\/div>\n<div id=\"su-post-33982\" class=\"su-post \">\n\t\t\t\t\t\t\t\t\t<a class=\"su-post-thumbnail\" href=\"https:\/\/getshortcodes.com\/docs\/photo-panel\/\"><img loading=\"lazy\" decoding=\"async\" width=\"120\" height=\"120\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2020\/10\/Photo-Panel.png\" class=\"attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2020\/10\/Photo-Panel.png 120w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2020\/10\/Photo-Panel-80x80.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2020\/10\/Photo-Panel-24x24.png 24w\" sizes=\"auto, (max-width: 120px) 100vw, 120px\" \/><\/a><\/p>\n<h2 class=\"su-post-title\"><a href=\"https:\/\/getshortcodes.com\/docs\/photo-panel\/\">Photo panel<\/a><\/h2>\n<\/p><\/div>\n<div id=\"su-post-33969\" class=\"su-post \">\n\t\t\t\t\t\t\t\t\t<a class=\"su-post-thumbnail\" href=\"https:\/\/getshortcodes.com\/docs\/post-meta\/\"><img loading=\"lazy\" decoding=\"async\" width=\"120\" height=\"120\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2020\/10\/Post-1.png\" class=\"attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2020\/10\/Post-1.png 120w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2020\/10\/Post-1-80x80.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2020\/10\/Post-1-24x24.png 24w\" sizes=\"auto, (max-width: 120px) 100vw, 120px\" \/><\/a><\/p>\n<h2 class=\"su-post-title\"><a href=\"https:\/\/getshortcodes.com\/docs\/post-meta\/\">Post Meta<\/a><\/h2>\n<\/p><\/div>\n<div id=\"su-post-33947\" class=\"su-post \">\n\t\t\t\t\t\t\t\t\t<a class=\"su-post-thumbnail\" href=\"https:\/\/getshortcodes.com\/docs\/tooltip\/\"><img loading=\"lazy\" decoding=\"async\" width=\"120\" height=\"120\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2020\/10\/Tooltip.png\" class=\"attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2020\/10\/Tooltip.png 120w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2020\/10\/Tooltip-80x80.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2020\/10\/Tooltip-24x24.png 24w\" sizes=\"auto, (max-width: 120px) 100vw, 120px\" \/><\/a><\/p>\n<h2 class=\"su-post-title\"><a href=\"https:\/\/getshortcodes.com\/docs\/tooltip\/\">Tooltip<\/a><\/h2>\n<\/p><\/div>\n<\/div>\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<p class=\"h2\">Table of contents<\/p>\n\n<ol><li><a href=\"#description\">Description<\/a><\/li><li><a href=\"#options\">Options<\/a><\/li><li><a href=\"#pagination\">Pagination<\/a><\/li><li><a href=\"#built-in-templates\">Built-in templates<\/a><ol><li><a href=\"#default-template\">Default template<\/a><\/li><li><a href=\"#teasers\">Teasers<\/a><\/li><li><a href=\"#single-post-template\">Single post template<\/a><\/li><li><a href=\"#list\">List<\/a><\/li><\/ol><\/li><li><a href=\"#template-editing\">Template editing<\/a><\/li><li><a href=\"#creating-custom-templates\">Creating custom templates<\/a><\/li><li><a href=\"#adding-custom-template-paths\">Adding custom template paths<\/a><\/li><\/ol><\/li><\/ol>\n\n\n<h2 class=\"wp-block-heading\" id=\"description\">Description<\/h2>\n\n\n\n<p>The&nbsp;<code>\n\n<div class=\"su-posts su-posts-default-loop \">\n\n\t\t\t<h4>Posts not found<\/h4>\n\t\n<\/div>\n<\/code>&nbsp;shortcode is intended for display of posts, pages, and various post types. You can display posts from a specific category or by a specific tag. You can also choose multiple taxonomies and select the number of displayed posts. This shortcode uses&nbsp;<a href=\"https:\/\/codex.wordpress.org\/Class_Reference\/WP_Query\">WP_Query<\/a>&nbsp;class.<\/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>template<\/strong><br><small>Relative path to the template file. Default templates placed in the plugin directory (templates folder). You can copy them under your theme directory and modify as you want. You can use following default templates that already available in the plugin directory:<br>templates\/default-loop.php &#8211; posts loop<br>templates\/teaser-loop.php &#8211; posts loop with thumbnail and title<br>templates\/single-post.php &#8211; single post template<br>templates\/list-loop.php &#8211; unordered list with posts titles<\/small><\/td><td>Any text value<\/td><td>templates\/default-loop.php<\/td><\/tr><tr><td><strong>id<\/strong><br><small>Enter comma separated ID&#8217;s of the posts that you want to show<\/small><\/td><td>Any text value<\/td><td><em>\u2013 none \u2013<\/em><\/td><\/tr><tr><td><strong>posts_per_page<\/strong><br><small>Specify number of posts that you want to show. Enter -1 to get all posts<\/small><\/td><td>Number from -1 to 10000<\/td><td>12<\/td><\/tr><tr><td><strong>post_type<\/strong><br><small>Select post types. Hold Ctrl key to select multiple post types<\/small><\/td><td>Post type slug(s) separated by comma(s)<\/td><td>post<\/td><\/tr><tr><td><strong>taxonomy<\/strong><br><small>Select taxonomy to show posts from<\/small><\/td><td>Taxonomy slug(s) separated by comma(s)<\/td><td>category<\/td><\/tr><tr><td><strong>tax_term<\/strong><br><small>Select terms to show posts from<\/small><\/td><td>Term slug(s) separated by comma(s)<\/td><td><em>\u2013 none \u2013<\/em><\/td><\/tr><tr><td><strong>tax_operator<\/strong><br><small>Operator to test<\/small><\/td><td>IN (IN &#8211; posts that have any of selected categories terms)<br>NOT IN (NOT IN &#8211; posts that is does not have any of selected terms)<br>AND (AND &#8211; posts that have all selected terms)<\/td><td>IN<\/td><\/tr><tr><td><strong>author<\/strong><br><small>Enter here comma-separated list of author&#8217;s IDs. Example: 1,7,18<\/small><\/td><td>Any text value<\/td><td><em>\u2013 none \u2013<\/em><\/td><\/tr><tr><td><strong>meta_key<\/strong><br><small>Enter meta key name to show posts that have this key<\/small><\/td><td>Any text value<\/td><td><em>\u2013 none \u2013<\/em><\/td><\/tr><tr><td><strong>offset<\/strong><br><small>Specify offset to start posts loop not from first post<\/small><\/td><td>Number from 0 to 10000<\/td><td>0<\/td><\/tr><tr><td><strong>order<\/strong><br><small>Posts order<\/small><\/td><td>desc (Descending)<br>asc (Ascending)<\/td><td>DESC<\/td><\/tr><tr><td><strong>orderby<\/strong><br><small>Order posts by<\/small><\/td><td>none (None)<br>id (Post ID)<br>author (Post author)<br>title (Post title)<br>name (Post slug)<br>date (Date)<br>modified (Last modified date)<br>parent (Post parent)<br>rand (Random)<br>comment_count (Comments number)<br>menu_order (Menu order)<br>meta_value (Meta key values)<br>meta_value_num (Meta key values (Numeric))<\/td><td>date<\/td><\/tr><tr><td><strong>post_parent<\/strong><br><small>Show childrens of entered post (enter post ID)<\/small><\/td><td>Any text value<\/td><td><em>\u2013 none \u2013<\/em><\/td><\/tr><tr><td><strong>post_status<\/strong><br><small>Show only posts with selected status<\/small><\/td><td>publish (Published)<br>pending (Pending)<br>draft (Draft)<br>auto-draft (Auto-draft)<br>future (Future post)<br>private (Private post)<br>inherit (Inherit)<br>trash (Trashed)<br>any (Any)<\/td><td>publish<\/td><\/tr><tr><td><strong>ignore_sticky_posts<\/strong><br><small>Set to \u201cyes\u201d to prevent sticky posts from being moved to the start of the returned list of posts. They are still included, but appear in regular order<\/small><\/td><td>yes or no<\/td><td>no<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"pagination\">Pagination<\/h2>\n\n\n\n<p>Unfortunately, pagination is currently not available in the shortcode. This function will be added in future versions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"built-in-templates\">Built-in templates<\/h2>\n\n\n\n<p><code>\n\n<div class=\"su-posts su-posts-default-loop \">\n\n\t\t\t<h4>Posts not found<\/h4>\n\t\n<\/div>\n<\/code>&nbsp;shortcode includes various templates which you can use to display your posts. Built-in templates are located in the following folder:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/wp-content\/plugins\/shortcodes-ultimate\/includes\/partials\/shortcodes\/posts\/templates\/<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"default-template\">Default template<\/h3>\n\n\n\n<p>The default template that includes post featured image, post date, title, excerpt, and comments link.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#091;su_posts template=\"templates\/default-loop.php\"]<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"887\" height=\"903\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-58-20.png\" alt=\"\" class=\"wp-image-37077\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-58-20.png 887w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-58-20-503x512.png 503w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-58-20-126x128.png 126w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-58-20-768x782.png 768w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-58-20-80x80.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-58-20-24x24.png 24w\" sizes=\"auto, (max-width: 887px) 100vw, 887px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"teasers\">Teasers<\/h3>\n\n\n\n<p>A simplified version of the default template which only includes post featured image and title.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#091;su_posts template=\"templates\/teaser-loop.php\"]<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"887\" height=\"903\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-58-48.png\" alt=\"\" class=\"wp-image-37078\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-58-48.png 887w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-58-48-503x512.png 503w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-58-48-126x128.png 126w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-58-48-768x782.png 768w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-58-48-80x80.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-58-48-24x24.png 24w\" sizes=\"auto, (max-width: 887px) 100vw, 887px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"single-post-template\">Single post template<\/h3>\n\n\n\n<p>A template which only shows a single post at a time. Includes post title, post date, comments link, and the post content.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#091;su_posts template=\"templates\/single-post.php\"]<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"887\" height=\"903\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-59-14.png\" alt=\"\" class=\"wp-image-37079\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-59-14.png 887w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-59-14-503x512.png 503w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-59-14-126x128.png 126w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-59-14-768x782.png 768w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-59-14-80x80.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-59-14-24x24.png 24w\" sizes=\"auto, (max-width: 887px) 100vw, 887px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"list\">List<\/h3>\n\n\n\n<p>A template that shows queried posts as a plain HTML list.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#091;su_posts template=\"templates\/list-loop.php\"]<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"887\" height=\"903\" src=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-59-41.png\" alt=\"\" class=\"wp-image-37080\" srcset=\"https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-59-41.png 887w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-59-41-503x512.png 503w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-59-41-126x128.png 126w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-59-41-768x782.png 768w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-59-41-80x80.png 80w, https:\/\/getshortcodes.com\/wp-content\/uploads\/2021\/01\/12-01-2021@19-59-41-24x24.png 24w\" sizes=\"auto, (max-width: 887px) 100vw, 887px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"template-editing\">Template editing<\/h2>\n\n\n\n<p class=\"has-black-color has-yellow-background-color has-text-color has-background\">Do not edit templates in the plugin folder, since all your changes will be lost after plugin update.<\/p>\n\n\n\n<p>To modify a built-in template you should copy it to your theme directory first. For convenience, you can copy the whole <code>templates<\/code> folder from the plugin folder.&nbsp; You can rename the copied folder, it doesn&#8217;t have to be <code>templates<\/code>. Resulting path to template files should look like so:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/wp-content\/themes\/THEME-NAME\/templates\/<\/code><\/pre>\n\n\n\n<p>Now you can edit copied template files.<\/p>\n\n\n\n<p>Use the&nbsp;<code>template<\/code>&nbsp;attribute to change the template used by shortcode. The value of this attribute must be a template file path relative to your theme&#8217;s folder. Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#091;su_posts template=\"templates\/default-loop.php\"]<\/code><\/pre>\n\n\n\n<p>In the example above the plugin will search for a template in the following locations (in the specified order):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/wp-content\/themes\/child-theme\/templates\/default-loop.php\n\/wp-content\/themes\/parent-theme\/templates\/default-loop.php\n\/wp-content\/plugins\/shortcodes-ultimate\/includes\/partials\/shortcodes\/posts\/templates\/default-loop.php<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"creating-custom-templates\">Creating custom templates<\/h2>\n\n\n\n<p>The&nbsp;<code>\n\n<div class=\"su-posts su-posts-default-loop \">\n\n\t\t\t<h4>Posts not found<\/h4>\n\t\n<\/div>\n<\/code>&nbsp;shortcode supports custom templates, which makes it incredibly powerful. Follow the steps below to create one.<\/p>\n\n\n\n<p><strong>Step 1<\/strong><\/p>\n\n\n\n<p>Create a new folder in your theme directory and name it <code>su-posts-templates<\/code>, so the resulting path would be:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/wp-content\/themes\/YOUR-THEME-NAME\/su-posts-templates\/<\/code><\/pre>\n\n\n\n<p><strong>Step 2<\/strong><\/p>\n\n\n\n<p>Create a new file in the <code>su-posts-templates<\/code> folder and name it <code>my-template.php<\/code>. The resulting path would be:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/wp-content\/themes\/YOUR-THEME-NAME\/su-posts-templates\/my-template.php<\/code><\/pre>\n\n\n\n<p><strong>Step 3<\/strong><\/p>\n\n\n\n<p>Put the following snippet into the created file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php if ( $posts-&gt;have_posts() ) : ?&gt;\n  &lt;div class=\"su-posts su-posts-my-template\"&gt;\n    &lt;?php while ( $posts-&gt;have_posts() ) : ?&gt;\n      &lt;?php $posts-&gt;the_post(); ?&gt;\n      &lt;a href=\"&lt;?php the_permalink(); ?&gt;\"&gt;&lt;?php the_title(); ?&gt;&lt;\/a&gt;\n    &lt;?php endwhile; ?&gt;\n  &lt;\/div&gt;\n&lt;?php else : ?&gt;\n  &lt;p&gt;Posts not found!&lt;\/p&gt;\n&lt;?php endif; ?&gt;<\/code><\/pre>\n\n\n\n<p><strong>Step 4<\/strong><\/p>\n\n\n\n<p>Now you can use the created template:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#091;su_posts template=\"su-posts-templates\/my-template.php\"]<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"adding-custom-template-paths\">Adding custom template paths<\/h2>\n\n\n\n<p>If you need to store your templates outside of the theme directory, you can extend the list of allowed template paths. Use the following snippet in a custom plugin or in the <code>functions.php<\/code> file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter(\n\t'su\/shortcode\/posts\/allowed_template_locations',\n\tfunction( $locations ) {\n\n\t\t\/\/ \/wp-content\/\n\t\t$locations&#091;] = WP_CONTENT_DIR;\n\n\t\treturn $locations;\n\n\t},\n\t10,\n\t1\n);<\/code><\/pre>\n\n\n\n<p>The code above will allow you to store templates under <code>\/wp-content\/<\/code> directory.<\/p>\n","protected":false},"featured_media":36642,"template":"","docs_category":[21],"class_list":["post-33821","docs","type-docs","status-publish","has-post-thumbnail","hentry","docs_category-shortcodes"],"_links":{"self":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs\/33821","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\/36642"}],"wp:attachment":[{"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/media?parent=33821"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/getshortcodes.com\/api\/wp\/v2\/docs_category?post=33821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}