{"id":299206,"date":"2021-08-03T13:07:54","date_gmt":"2021-08-03T13:07:54","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=299206"},"modified":"2024-07-31T13:28:55","modified_gmt":"2024-07-31T13:28:55","slug":"magento-2-development-23-blog-listing","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/","title":{"rendered":"Magento 2 Development 26: Blog Listing"},"content":{"rendered":"\n<p>In this blog, we will show the published and approved blogs on the front end. <\/p>\n\n\n\n<p>This will be our first public page since all of the pages before it required some kind of authentication either customer or admin.<\/p>\n\n\n\n<p>That means guest users also will be able to access this page.<\/p>\n\n\n\n<p>The URL for the blog listing page will be <strong>http:\/\/hostname\/blog<\/strong>. <\/p>\n\n\n\n<p>For now, you will have to directly browse the page. But in the next blog, we will add menus for this page.<\/p>\n\n\n\n<p>So let&#8217;s create the controller file, <em>Controller\/Index\/Index.php<\/em><\/p>\n\n\n\n<p>Code for <em>Controller\/Index\/Index.php<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\BlogManager\\Controller\\Index;\n\nuse Magento\\Framework\\App\\Action\\Context;\nuse Magento\\Framework\\View\\Result\\PageFactory;\n\nclass Index extends \\Magento\\Framework\\App\\Action\\Action\n{\n    \/**\n     * @var Magento\\Framework\\View\\Result\\PageFactory\n     *\/\n    protected $resultPageFactory;\n\n    \/**\n     * Dependency Initilization\n     *\n     * @param Context $context\n     * @param PageFactory $resultPageFactory\n     *\/\n    public function __construct(\n        Context $context,\n\t    PageFactory $resultPageFactory\n    ) {\n\t    $this-&gt;resultPageFactory = $resultPageFactory;\n        parent::__construct($context);\n    }\n\n    \/**\n     * Provides content\n     *\n     * @return \\Magento\\Framework\\View\\Result\\Page\n     *\/\n    public function execute()\n    {\n        $resultPage = $this-&gt;resultPageFactory-&gt;create();\n        $resultPage-&gt;getConfig()-&gt;getTitle()-&gt;set(__(&#039;Blogs&#039;));\n        $layout = $resultPage-&gt;getLayout();\n        return $resultPage;\n    }\n}<\/pre>\n\n\n\n<p>One thing to note here is that we have extended <strong>\\Magento\\Framework\\App\\Action\\Action<\/strong> and not the customer abstract account. <\/p>\n\n\n\n<p>That&#8217;s because this page will be accessible to guest users also.<\/p>\n\n\n\n<p>Now the next step is to create the layout file <em>view\/frontend\/layout\/blogmanager_index_index.xml<\/em><\/p>\n\n\n\n<p>Code for <em>view\/frontend\/layout\/blogmanager_index_index.xml<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;page xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; layout=&quot;1column&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd&quot;&gt;\n    &lt;head&gt;\n\t\t&lt;css src=&quot;Webkul_BlogManager::css\/style.css&quot;\/&gt;\n\t&lt;\/head&gt;\n    &lt;body&gt;\n        &lt;referenceContainer name=&quot;content&quot;&gt;\n            &lt;block class=&quot;Webkul\\BlogManager\\Block\\Published\\BlogList&quot; name=&quot;blogmanager.blog.published.list&quot; template=&quot;Webkul_BlogManager::published\/list.phtml&quot; \/&gt;\n        &lt;\/referenceContainer&gt;\n    &lt;\/body&gt;\n&lt;\/page&gt;<\/pre>\n\n\n\n<p>Note here we have used <strong>layout=&#8221;1column&#8221;<\/strong> instead of the 2column layout pattern. <\/p>\n\n\n\n<p>Also, we have not used the update handle code here because that was required to load the base structure of customer account pages. <\/p>\n\n\n\n<p>And we have added the CSS node which will load the style file.<\/p>\n\n\n\n<p>Let&#8217;s create the template file now <em>view\/frontend\/templates\/published\/list.phtml<\/em><\/p>\n\n\n\n<p>Code for <em>view\/frontend\/templates\/published\/list.phtml<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php \n$blogs = $block-&gt;getCollection();\n?&gt;\n&lt;div class=&quot;blog-collection-wrapper&quot;&gt;\n    &lt;div class=&quot;blog-published&quot;&gt;\n        &lt;?php\n        foreach ($blogs as $blog) { ?&gt;\n            &lt;div class=&quot;blog-item&quot;&gt;\n                &lt;div class=&quot;blog-item-title&quot;&gt;\n                    &lt;a href=&quot;&lt;?= $escaper-&gt;escapeUrl($block-&gt;getUrl(&#039;blog\/index\/view&#039;, &#091;&#039;id&#039;=&gt;$escaper-&gt;escapeHtml($blog-&gt;getId())]))?&gt;&quot;&gt;&lt;?= $escaper-&gt;escapeHtml($blog-&gt;getTitle()); ?&gt;&lt;\/a&gt;\n                &lt;\/div&gt;\n                &lt;div class=&quot;blog-item-details&quot;&gt;\n                    &lt;div&gt;&lt;?= __(&quot;Created At:&quot;).&#039; &#039;.$escaper-&gt;escapeHtml($block-&gt;getFormattedDate($escaper-&gt;escapeHtml($blog-&gt;getCreatedAt()))); ?&gt;&lt;\/div&gt;\n                    &lt;div&gt;&lt;?= __(&quot;Author:&quot;).&#039; &#039;.$block-&gt;getAuthor($blog-&gt;getUserId()); ?&gt;&lt;\/div&gt;\n                &lt;\/div&gt;\n                &lt;div class=&quot;blog-item-content&quot;&gt;\n                    &lt;?= strlen($escaper-&gt;escapeHtml($blog-&gt;getContent()))&lt;100 ? $escaper-&gt;escapeHtml($blog-&gt;getContent()) : substr($escaper-&gt;escapeHtml($blog-&gt;getContent()),0,100).&#039;...&#039;; ?&gt;\n                    &lt;div class=&quot;blog-item-view&quot;&gt;\n                        &lt;a href=&quot;&lt;?= $escaper-&gt;escapeUrl($block-&gt;getUrl(&#039;blog\/index\/view&#039;, &#091;&#039;id&#039;=&gt;$escaper-&gt;escapeHtml($blog-&gt;getId())]))?&gt;&quot;&gt;&lt;?= __(&#039;view&#039;); ?&gt;&lt;\/a&gt;\n                    &lt;\/div&gt;\n                &lt;\/div&gt;\n            &lt;\/div&gt;\n        &lt;?php\n        } ?&gt;\n        &lt;?= $block-&gt;getPagerHtml(); ?&gt;\n    &lt;\/div&gt;\n&lt;\/div&gt;<\/pre>\n\n\n\n<p>We have loaded all the blogs with the <strong>getCollection<\/strong> method, which we will create in the block. <\/p>\n\n\n\n<p>Then we looped over each blog to show data about them.<\/p>\n\n\n\n<p>We have added links to view the blog page which we will create in the next blogs. <\/p>\n\n\n\n<p>Also, we have used <strong>getFormattedDate<\/strong> and <strong>getAuthor<\/strong> which we will create in block. <\/p>\n\n\n\n<p>We have displayed the first 100 characters of blog content.<\/p>\n\n\n\n<p>Also, we have called <strong>getPagerHtml<\/strong> to get the pagination when we have lots of blogs. <\/p>\n\n\n\n<p>Now let&#8217;s see the block class <em>Block\/Published\/BlogList.php<\/em><\/p>\n\n\n\n<p>Code for <em>Block\/Published\/BlogList.php<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\BlogManager\\Block\\Published;\n\nclass BlogList extends \\Magento\\Framework\\View\\Element\\Template\n{\n    \/**\n     * @var \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\CollectionFactory\n     *\/\n    protected $blogCollection;\n\n    \/**\n     * @var \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\Collection\n     *\/\n    protected $blogList;\n\n    \/**\n     * @var \\Webkul\\BlogManager\\Helper\\Data\n     *\/\n    protected $helper;\n\n    \/**\n     * @var \\Magento\\Customer\\Model\\CustomerFactory\n     *\/\n    protected $customerFactory;\n\n    \/**\n     * Dependency Initilization\n     *\n     * @param \\Magento\\Framework\\View\\Element\\Template\\Context $context\n     * @param \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\CollectionFactory $blogCollection\n     * @param \\Webkul\\BlogManager\\Helper\\Data $helper\n     * @param \\Magento\\Customer\\Model\\CustomerFactory $customerFactory\n     * @param array $data\n     *\/\n    public function __construct(\n        \\Magento\\Framework\\View\\Element\\Template\\Context $context,\n        \\Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\CollectionFactory $blogCollection,\n        \\Webkul\\BlogManager\\Helper\\Data $helper,\n        \\Magento\\Customer\\Model\\CustomerFactory $customerFactory,\n        array $data = &#091;]\n    ) {\n        $this-&gt;helper = $helper;\n        $this-&gt;blogCollection = $blogCollection;\n        $this-&gt;customerFactory = $customerFactory;\n        parent::__construct($context, $data);\n    }\n\n    \/**\n     * Get Blog Collection\n     *\n     * @return Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\Collection\n     *\/\n    public function getCollection()\n    {\n        if (!$this-&gt;blogList) {\n            $collection = $this-&gt;blogCollection-&gt;create();\n            $collection-&gt;addFieldToFilter(&#039;status&#039;, 1);\n            $collection-&gt;setOrder(&#039;created_at&#039;, &#039;DESC&#039;);\n            $this-&gt;blogList = $collection;\n        }\n        return $this-&gt;blogList;\n    }\n\n    \/**\n     * Prepare Layout\n     *\n     * @return this\n     *\/\n    protected function _prepareLayout()\n    {\n        parent::_prepareLayout();\n        if ($this-&gt;getCollection()) {\n            $pager = $this-&gt;getLayout()-&gt;createBlock(\n                \\Magento\\Theme\\Block\\Html\\Pager::class,\n                &#039;blogmanager.publishedblog.pager&#039;\n            )\n            -&gt;setCollection(\n                $this-&gt;getCollection()\n            );\n            $this-&gt;setChild(&#039;pager&#039;, $pager);\n            $this-&gt;getCollection()-&gt;load();\n        }\n        return $this;\n    }\n\n    \/**\n     * Get Pager Html\n     *\n     * @return void\n     *\/\n    public function getPagerHtml()\n    {\n        return $this-&gt;getChildHtml(&#039;pager&#039;);\n    }\n\n    \/**\n     * Get Author Name\n     *\n     * @param int $userId\n     * @return string\n     *\/\n    public function getAuthor($userId)\n    {\n        if ($userId) {\n            $customer = $this-&gt;customerFactory-&gt;create()-&gt;load($userId);\n            if ($customer &amp;&amp; $customer-&gt;getId()) {\n                return $customer-&gt;getName();\n            }\n        }\n        return __(&#039;Admin&#039;);\n    }\n\n    \/**\n     * Get Formatted Date\n     *\n     * @param string $date\n     * @return date\n     *\/\n    public function getFormattedDate($date)\n    {\n        return $this-&gt;helper-&gt;getFormattedDate($date);\n    }\n}<\/pre>\n\n\n\n<p>There are multiple things to notice here. First, we loaded the blogs based on status and sorted them by created date in the <strong>getCollection<\/strong> method. <\/p>\n\n\n\n<p>After loading it we have set the collection in <strong>$this->blogList<\/strong> field variable. <\/p>\n\n\n\n<p><strong>if (!$this->blogList)<\/strong> this ensures that we load the collection only once for a page load. <\/p>\n\n\n\n<p>Because if you see we have called the <strong>getCollection<\/strong> multiple times in <strong>_prepareLayout<\/strong> and also in the template file.<\/p>\n\n\n\n<p>So it will ensure that we load the collection only once and save the data for future function calls.<\/p>\n\n\n\n<p>We need the <strong>_prepareLayout<\/strong> function so that the pagination works. <\/p>\n\n\n\n<p>Because we have not created code for the pager but used Magento&#8217;s pagination.<\/p>\n\n\n\n<p>In <strong>getPagerHtml<\/strong>, we have called for a child html called <strong>pager<\/strong>. <\/p>\n\n\n\n<p>This will be responsible for showing the pager based on the collection that we provide in prepare layout function.<\/p>\n\n\n\n<p>The <strong>getAuthor<\/strong> is used to get the author&#8217;s name based on the id. We have loaded the customer model and got the name.<\/p>\n\n\n\n<p>If the id is 0 or if the customer with that id does not exist then it will return &#8216;Admin&#8217;.<\/p>\n\n\n\n<p>For formatting dates, I have created a function <strong>getFormattedDate<\/strong> which again calls a function of the same from the helper. <\/p>\n\n\n\n<p>We will create this function in Helper.<\/p>\n\n\n\n<p>Now let&#8217;s edit the helper class <em>Helper\/Data.php<\/em><\/p>\n\n\n\n<p>Updated code for <em>Helper\/Data.php<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\BlogManager\\Helper;\n\nuse Magento\\Customer\\Model\\Session;\n\nclass Data extends \\Magento\\Framework\\App\\Helper\\AbstractHelper\n{\n    \/**\n     * @var Magento\\Customer\\Model\\Session\n     *\/\n    protected $customerSession;\n\n    \/**\n     * @var \\Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface\n     *\/\n    protected $date;\n    \n    \/**\n     * Dependency Initilization\n     *\n     * @param Session $customerSession\n     * @param \\Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface $date\n     * @param \\Magento\\Framework\\App\\Helper\\Context $context\n     *\/\n    public function __construct(\n        Session $customerSession,\n        \\Magento\\Framework\\Stdlib\\DateTime\\TimezoneInterface $date,\n        \\Magento\\Framework\\App\\Helper\\Context $context\n    ) {\n        $this-&gt;customerSession = $customerSession;\n        $this-&gt;date = $date;\n        parent::__construct($context);\n    }\n\n    \/**\n     * Get Customer Id\n     *\n     * @return int\n     *\/\n    public function getCustomerId()\n    {\n        $customerId = $this-&gt;customerSession-&gt;getCustomerId();\n        return $customerId;\n    }\n\n    \/**\n     * Get Formatted Date\n     *\n     * @param string $date\n     * @return date\n     *\/\n    public function getFormattedDate($date=&#039;&#039;)\n    {\n        return $this-&gt;date-&gt;date($date)-&gt;format(&#039;d\/m\/y h:i A&#039;);\n    }\n}<\/pre>\n\n\n\n<p>Here we have just added the function to format date.<\/p>\n\n\n\n<p>We also need to do some styling so that the page looks good. So let&#8217;s edit the <em>view\/frontend\/web\/css\/style.css<\/em><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">.blog-form .blog-form-field-container {\n    margin: 15px auto;\n}\n.blog-form .blog-form-action-container {\n    text-align: center;\n}\n.blog-form .blog-form-action-container .blog-form-action {\n    min-width: 150px;\n    padding: 10px;\n    font-size: 16px;\n    background: #2b4c8a;\n    color: white;\n}\n.blog-collection-wrapper {\n    max-width: 1000px;\n    margin: 0 auto;\n}\n.blog-published .blog-item-title {\n    font-size: 20px;\n    margin-bottom: 5px;\n}\n.blog-published .blog-item-title a:hover {\n    text-decoration: none;\n}\n.blog-published .blog-item-details div {\n    display: inline-block;\n    margin-right: 25px;\n    margin-bottom: 10px;\n    color: gray;\n}\n.blog-published .blog-item-content .blog-item-view {\n    margin-top: 5px;\n    text-decoration: underline;\n}\n.blog-published {\n    margin-top: -20px\n}\n.blog-published .blog-item {\n    border-bottom: 1px solid #cccccc;\n    padding-bottom: 20px;\n    padding-top: 30px;\n}<\/pre>\n\n\n\n<p>Now when you browse the URL. You should see all the blogs as shown below,<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"625\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11-1200x625.png\" alt=\"2021-08-03_18-11\" class=\"wp-image-299273\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11-1200x625.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11-300x156.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11-250x130.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11-768x400.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11-1536x800.png 1536w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11.png 1738w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Also, you can see the pagination at the bottom,<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"504\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-12-1-1200x504.png\" alt=\"2021-08-03_18-12-1\" class=\"wp-image-299276\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-12-1-1200x504.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-12-1-300x126.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-12-1-250x105.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-12-1-768x322.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-12-1-1536x645.png 1536w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-12-1.png 1742w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p><br><\/p>\n\n\n\n<p>Next Blog -&gt; <a href=\"https:\/\/webkul.com\/blog\/magento-2-development-24-front-end-menus\/\">Magento 2 Development 27: Front-end Menus<\/a><\/p>\n\n\n\n<p>Previous Blog ->\u00a0<a href=\"https:\/\/webkul.com\/blog\/magento-2-development-22-helper\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 Development 25: Helper<\/a><\/p>\n\n\n\n<p>Furthermore, there is no necessity to look beyond this point; take advantage of the opportunity to initiate your projects with the recommended\u00a0<a href=\"https:\/\/webkul.com\/magento-development\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 development company<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, we will show the published and approved blogs on the front end. This will be our first public page since all of the pages before it required some kind of authentication either customer or admin. That means guest users also will be able to access this page. The URL for the blog <a href=\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":201,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9121],"tags":[2056,2460,2070],"class_list":["post-299206","post","type-post","status-publish","format-standard","hentry","category-magento-2","tag-magento","tag-magento-2","tag-magento2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Magento 2 Development 26: Blog Listing - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Magento 2 Development 26: Blog Listing - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"In this blog, we will show the published and approved blogs on the front end. This will be our first public page since all of the pages before it required some kind of authentication either customer or admin. That means guest users also will be able to access this page. The URL for the blog [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-03T13:07:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-31T13:28:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11-1200x625.png\" \/>\n<meta name=\"author\" content=\"Sanjay Chouhan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sanjay Chouhan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/\"},\"author\":{\"name\":\"Sanjay Chouhan\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462\"},\"headline\":\"Magento 2 Development 26: Blog Listing\",\"datePublished\":\"2021-08-03T13:07:54+00:00\",\"dateModified\":\"2024-07-31T13:28:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/\"},\"wordCount\":659,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11-1200x625.png\",\"keywords\":[\"magento\",\"Magento 2\",\"Magento2\"],\"articleSection\":[\"Magento 2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/\",\"url\":\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/\",\"name\":\"Magento 2 Development 26: Blog Listing - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11-1200x625.png\",\"datePublished\":\"2021-08-03T13:07:54+00:00\",\"dateModified\":\"2024-07-31T13:28:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11.png\",\"width\":1738,\"height\":905,\"caption\":\"2021-08-03_18-11\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Magento 2 Development 26: Blog Listing\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462\",\"name\":\"Sanjay Chouhan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Sanjay Chouhan\"},\"sameAs\":[\"https:\/\/www.instagram.com\/sanjaychouhansc\/\",\"https:\/\/in.linkedin.com\/in\/scchouhansanjay\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/sanjay-chouhan180\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Magento 2 Development 26: Blog Listing - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/","og_locale":"en_US","og_type":"article","og_title":"Magento 2 Development 26: Blog Listing - Webkul Blog","og_description":"In this blog, we will show the published and approved blogs on the front end. This will be our first public page since all of the pages before it required some kind of authentication either customer or admin. That means guest users also will be able to access this page. The URL for the blog [...]","og_url":"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2021-08-03T13:07:54+00:00","article_modified_time":"2024-07-31T13:28:55+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11-1200x625.png","type":"","width":"","height":""}],"author":"Sanjay Chouhan","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Sanjay Chouhan","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/"},"author":{"name":"Sanjay Chouhan","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462"},"headline":"Magento 2 Development 26: Blog Listing","datePublished":"2021-08-03T13:07:54+00:00","dateModified":"2024-07-31T13:28:55+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/"},"wordCount":659,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11-1200x625.png","keywords":["magento","Magento 2","Magento2"],"articleSection":["Magento 2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/","url":"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/","name":"Magento 2 Development 26: Blog Listing - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11-1200x625.png","datePublished":"2021-08-03T13:07:54+00:00","dateModified":"2024-07-31T13:28:55+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/2021-08-03_18-11.png","width":1738,"height":905,"caption":"2021-08-03_18-11"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/magento-2-development-23-blog-listing\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Magento 2 Development 26: Blog Listing"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462","name":"Sanjay Chouhan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Sanjay Chouhan"},"sameAs":["https:\/\/www.instagram.com\/sanjaychouhansc\/","https:\/\/in.linkedin.com\/in\/scchouhansanjay"],"url":"https:\/\/webkul.com\/blog\/author\/sanjay-chouhan180\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/299206","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/201"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=299206"}],"version-history":[{"count":10,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/299206\/revisions"}],"predecessor-version":[{"id":455654,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/299206\/revisions\/455654"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=299206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=299206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=299206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}