{"id":427,"date":"2023-10-21T06:21:35","date_gmt":"2023-10-21T06:21:35","guid":{"rendered":"https:\/\/wpshortcode.org\/?p=427"},"modified":"2023-10-21T06:21:36","modified_gmt":"2023-10-21T06:21:36","slug":"list-category-posts","status":"publish","type":"post","link":"https:\/\/wpshortcode.org\/list-category-posts\/","title":{"rendered":"List category posts Shortcode"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Below, you&#8217;ll find a detailed guide on how to add the <strong>List category posts 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 List category posts 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 List category posts 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\/list-category-posts\/assets\/icon-128x128.png?rev=2517221\" 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\/list-category-posts\" target=\"_blank\" rel=\"noopener\">\n                        List category posts                    <\/a>\n\n\n                <!-- Plugin Description -->\n                <p class=\"plugin-description\">\n                    &quot;List Category Posts is a powerful WordPress plugin designed to display posts from specific categories on your pages and widgets, enhancing content organization.&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> (250)\n            <\/span>\n            <span class=\"plugin-active-installs\">\n                <strong>Active Installs<\/strong>: 100000+\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>: 5.6            <\/span>\n        <\/div>\n\n        <!-- List of Included Shortcodes -->\n        <div class=\"plugin-shortcodes\">\n            <strong>Included Shortcodes:<\/strong>\n            <ul>\n                <li>[catlist]<\/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\">List category posts [catlist] Shortcode<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The List Category Posts shortcode allows you to display a list of posts from a specific category. \n\n\n\nThe shortcode function &#8216;catlist_func&#8217; takes attributes, applies default parameters, and checks for number of posts and pagination settings. If pagination is enabled, it applies the relevant CSS. The function then creates a new instance of CatListDisplayer with the given attributes, and returns the display.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Shortcode<\/strong>: <code>[catlist]<\/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 catlist shortcode parameters and attributes:<\/p>\n\n\n<ul>\n<li><code>numberposts<\/code> &#8211; Determines the number of posts to display.<\/li>\n<li><code>pagination<\/code> &#8211; Controls whether to show pagination or not.<\/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 straightforward usage of the &#8216;catlist&#8217; shortcode to display posts from a specific category. Here, we&#8217;re using &#8216;3&#8217; as the category ID.<\/p>\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">[catlist id=3 \/]<\/code><\/pre>\n\n\n<p><strong>Advanced examples<\/strong><\/p>\n<p>Displaying posts from multiple categories. In this example, we&#8217;re displaying posts from categories with IDs &#8216;3&#8217; and &#8216;5&#8217;.<\/p>\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">[catlist id=\"3,5\" \/]<\/code><\/pre>\n\n\n<p>Limiting the number of posts displayed. Here, we&#8217;re displaying only the 5 most recent posts from category &#8216;3&#8217;.<\/p>\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">[catlist id=3 numberposts=5 \/]<\/code><\/pre>\n\n\n<p>Enabling pagination for the displayed posts. This will add navigation links to view more posts from the specified category.<\/p>\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">[catlist id=3 pagination=yes \/]<\/code><\/pre>\n\n\n<p>Combining multiple parameters. In this example, we&#8217;re displaying the 5 most recent posts from categories &#8216;3&#8217; and &#8216;5&#8217;, with pagination enabled.<\/p>\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">[catlist id=\"3,5\" numberposts=5 pagination=yes \/]<\/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>[catlist]<\/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( 'catlist', array('ListCategoryPosts', 'catlist_func') );<\/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 catlist_func($atts) {\n    \/\/ Can be filtered using the shortcode_atts_catlist hook.\n    $atts = shortcode_atts(self::default_params(), $atts, &#039;catlist&#039;);\n\n    if($atts&#91;&#039;numberposts&#039;] == &#039;&#039;){\n      $atts&#91;&#039;numberposts&#039;] = get_option(&#039;numberposts&#039;);\n    }\n    if($atts&#91;&#039;pagination&#039;] == &#039;yes&#039; ||\n       (get_option(&#039;lcp_pagination&#039;) === &#039;true&#039; &amp;&amp;\n        $atts&#91;&#039;pagination&#039;] !== &#039;false&#039;) ){\n      lcp_pagination_css();\n    }\n    $catlist_displayer = new CatListDisplayer($atts);\n    return $catlist_displayer-&gt;display();\n  }\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\">list-category-posts\/list-category-posts\/list-category-posts.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>List category posts 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 List category posts 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 List category posts 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":"List category posts","slug":"","version":"0.89","author":"<a href=\"http:\/\/fernandobriano.com\">Fernando Briano<\/a>","icons":"https:\/\/ps.w.org\/list-category-posts\/assets\/icon-128x128.png?rev=2517221","plugin_tags":"{\"categories\":\"categories\",\"cms\":\"cms\",\"list\":\"list\",\"posts\":\"posts\"}","author_profile":"https:\/\/profiles.wordpress.org\/fernandobt\/","requires":"3.3","tested":"6.3.2","requires_php":"5.6","rating":94,"num_ratings":250,"active_installs":100000,"downloaded":3520526,"last_updated":"2023-09-05 5:25pm GMT","added":"2008-08-16","homepage":"https:\/\/github.com\/picandocodigo\/List-Category-Posts","short_description":"List Category Posts allows you to list posts by category and many other parameters in a post, page or widget. You use the [catlist] shortcode to selec &hellip;","description":"\"List Category Posts is a powerful WordPress plugin designed to display posts from specific categories on your pages and widgets, enhancing content organization.\"","shortcodes":"[\"catlist\"]","footnotes":""},"categories":[1],"tags":[],"class_list":["post-427","post","type-post","status-publish","format-standard","hentry","category-plugins"],"_links":{"self":[{"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts\/427","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=427"}],"version-history":[{"count":1,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts\/427\/revisions"}],"predecessor-version":[{"id":561,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/posts\/427\/revisions\/561"}],"wp:attachment":[{"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/media?parent=427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/categories?post=427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpshortcode.org\/wp-json\/wp\/v2\/tags?post=427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}