{"id":1243,"date":"2023-10-26T13:21:03","date_gmt":"2023-10-26T13:21:03","guid":{"rendered":"https:\/\/wpshortcode.org\/?p=1243"},"modified":"2023-10-26T13:21:04","modified_gmt":"2023-10-26T13:21:04","slug":"post-carousel","status":"publish","type":"post","link":"https:\/\/wpshortcode.org\/post-carousel\/","title":{"rendered":"Post Carousel Shortcode"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Below, you&#8217;ll find a detailed guide on how to add the <strong>Post Carousel 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 Post Carousel 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 Post Carousel 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\/post-carousel\/assets\/icon-128x128.png?rev=2436645\" 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\/post-carousel\" target=\"_blank\" rel=\"noopener\">\n                        Post Grid, Post Carousel, &amp; List Category Posts \u2013 by Smart Post Show                    <\/a>\n\n\n                <!-- Plugin Description -->\n                <p class=\"plugin-description\">\n                    &quot;Post Grid, Post Carousel, &amp; List Category Posts by Smart Post Show is a dynamic plugin used to create engaging layouts for your posts. It easily organizes content into grids, carousels, or lists.&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\u2606<\/span> (154)\n            <\/span>\n            <span class=\"plugin-active-installs\">\n                <strong>Active Installs<\/strong>: 20000+\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>: false            <\/span>\n        <\/div>\n\n        <!-- List of Included Shortcodes -->\n        <div class=\"plugin-shortcodes\">\n            <strong>Included Shortcodes:<\/strong>\n            <ul>\n                <li>[smart_post_show]<\/li>            <\/ul>\n        <\/div>\n    <\/div>\n    <\/p>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Post Carousel [smart_post_show] Shortcode<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Smart Post Show shortcode is a versatile tool for displaying post carousels. It fetches a specific post carousel&#8217;s settings based on its ID, checks its existence and status, and retrieves its layout and view options. \n\n\n\nIt also determines if the current page already contains the shortcode. If not, it enqueues necessary stylesheets and applies dynamic styles. Finally, it outputs the post carousel HTML.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Shortcode<\/strong>: <code>[smart_post_show]<\/code><\/p>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\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 smart_post_show shortcode parameters and attributes:<\/p>\n\n\n<ul>\n<li><code>id<\/code> &#8211; The unique identifier for the specific post carousel<\/li>\n<\/ul>\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Examples and Usage<\/h3>\n\n\n<p><strong>Basic example<\/strong> &#8211; A simple usage of the shortcode to display a post carousel with a specific id.<\/p>\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">[smart_post_show id=1 \/]<\/code><\/pre>\n\n\n<p><strong>Advanced examples<\/strong><\/p>\n<p>Using the shortcode to display a post carousel with a specific id and applying a specific layout and view options. The carousel will load with the specified layout and view options.<\/p>\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">\n\/\/ Add the layout and view options in the post meta\nupdate_post_meta( 1, 'sp_pcp_layouts', 'layout1' );\nupdate_post_meta( 1, 'sp_pcp_view_options', array( 'option1', 'option2' ) );\n\n\/\/ Use the shortcode\necho do_shortcode( '[smart_post_show id=1 \/]' );\n<\/code><\/pre>\n\n\n<p>Using the shortcode to display a post carousel with a specific id and applying a specific layout and view options. The carousel will load with the specified layout and view options. If the specified id is not found or the post status is &#8216;trash&#8217;, the shortcode will not render anything.<\/p>\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">\n\/\/ Add the layout and view options in the post meta\nupdate_post_meta( 2, 'sp_pcp_layouts', 'layout2' );\nupdate_post_meta( 2, 'sp_pcp_view_options', array( 'option3', 'option4' ) );\n\n\/\/ Use the shortcode\necho do_shortcode( '[smart_post_show id=2 \/]' );\n<\/code><\/pre>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\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>[smart_post_show]<\/code> shortcode, check below the related PHP functions code.<\/p>\n\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( 'smart_post_show', array( $this, 'pcp_shortcode_render' ) );<\/code><\/pre>\n\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=\"\">\nfunction pcp_shortcode_render( $attribute ) {\n\t\t$shortcode_id = esc_attr( intval( $attribute&#91;&#039;id&#039;] ) );\n\t\t\/\/ Check the shortcode existence and status.\n\t\tif ( empty( $shortcode_id ) || &#039;sp_post_carousel&#039; !== get_post_type( $shortcode_id ) || &#039;trash&#039; === get_post_status( $shortcode_id ) ) {\n\t\t\treturn;\n\t\t}\n\t\t\/\/ Preset Layouts.\n\t\t$layout = get_post_meta( $shortcode_id, &#039;sp_pcp_layouts&#039;, true );\n\t\t\/\/ All the visible options for the Shortcode like \u2013 Global, Filter, Display, Popup, Typography etc.\n\t\t$view_options  = get_post_meta( $shortcode_id, &#039;sp_pcp_view_options&#039;, true );\n\t\t$section_title = get_the_title( $shortcode_id );\n\n\t\t\/\/ Get the existing shortcode id from the current page.\n\t\t$get_page_data      = self::get_page_data();\n\t\t$found_shortcode_id = $get_page_data&#91;&#039;generator_id&#039;];\n\t\tob_start();\n\t\t\/\/ Check if shortcode and page ids are not exist in the current page then enqueue the stylesheet.\n\t\tif ( ! is_array( $found_shortcode_id ) || ! $found_shortcode_id || ! in_array( $shortcode_id, $found_shortcode_id ) ) {\n\t\t\twp_enqueue_style( &#039;font-awesome&#039; );\n\t\t\twp_enqueue_style( &#039;pcp_swiper&#039; );\n\t\t\twp_enqueue_style( &#039;pcp-style&#039; );\n\t\t\t$dynamic_style = self::load_dynamic_style( $shortcode_id, $view_options, $layout );\n\t\t\t\/\/ Add dynamic style.\n\t\t\techo &#039;&lt;style id=&quot;sp_pcp_dynamic_style&#039; . esc_attr( $shortcode_id ) . &#039;&quot;&gt;&#039; . $dynamic_style&#91;&#039;dynamic_css&#039;] . &#039;&lt;\/style&gt;&#039;; \/\/ phpcs:ignore\n\t\t}\n\t\t\/\/ Update options if the existing shortcode id option not found.\n\t\tself::sps_db_options_update( $shortcode_id, $get_page_data );\n\t\tSP_PC_Output::pc_html_show( $view_options, $layout, $shortcode_id, $section_title );\n\t\treturn ob_get_clean();\n\t}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>Code file location<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">post-carousel\/post-carousel\/public\/class-smart-post-show-public.php<\/code><\/pre>\n\n\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>Post Carousel 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 Post Carousel 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 Post Carousel Plugin shortcode not to show or not to work correctly. Before starting, here is an overview [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"name":"Post Grid, Post Carousel, &amp; List Category Posts \u2013 by Smart Post Show","slug":"","version":"2.4.24","author":"<a href=\"https:\/\/shapedplugin.com\/\">ShapedPlugin LLC<\/a>","icons":"https:\/\/ps.w.org\/post-carousel\/assets\/icon-128x128.png?rev=2436645","plugin_tags":"{\"list-category-post\":\"list category post\",\"post-carousel\":\"post carousel\",\"post-grid\":\"post grid\",\"posts-list\":\"posts list\",\"smart-post-show\":\"smart post show\"}","author_profile":"https:\/\/profiles.wordpress.org\/shapedplugin\/","requires":"4.7","tested":"6.3.2","requires_php":"false","rating":94,"num_ratings":154,"active_installs":20000,"downloaded":450358,"last_updated":"2023-08-22 11:56am GMT","added":"2016-09-21","homepage":"https:\/\/smartpostshow.com\/","short_description":"Smart Post Show allows you to filter and display posts, pages, taxonomy (categories, tags, &amp; post formats) in the beautiful carousel and grid layo &hellip;","description":"\"Post Grid, Post Carousel, & List Category Posts by Smart Post Show is a dynamic plugin used to create engaging layouts for your posts. It easily organizes content into grids, carousels, or lists.\"","shortcodes":"[\"smart_post_show\"]","footnotes":""},"categories":[1],"tags":[],"class_list":["post-1243","post","type-post","status-publish","format-standard","hentry","category-plugins"],"_links":{"self":[{"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts\/1243","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=1243"}],"version-history":[{"count":1,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts\/1243\/revisions"}],"predecessor-version":[{"id":1510,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts\/1243\/revisions\/1510"}],"wp:attachment":[{"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/media?parent=1243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/categories?post=1243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/tags?post=1243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}