{"id":7905,"date":"2011-04-08T04:58:28","date_gmt":"2011-04-08T08:58:28","guid":{"rendered":"http:\/\/info.template-help.com\/?p=7905"},"modified":"2020-01-30T11:13:07","modified_gmt":"2020-01-30T16:13:07","slug":"how-to-create-recent-posts-page","status":"publish","type":"post","link":"https:\/\/www.templatemonster.com\/help\/how-to-create-recent-posts-page.html","title":{"rendered":"How to create recent posts page"},"content":{"rendered":"<p>\r\n<p>This tutorial will show you how to create a recent posts list page in WordPress. In other words you&#8217;ll learn how to create a page that will display recent posts title in a list format. <\/p>\r\n<p class=\"attention\">Before you start this tutorial please make sure you learned how to <a href=\"\/help\/how-to-add-pages-in-wordpress.html\">add pages<\/a> and create page templates in WordPress. <\/p>\r\n<p>1. Access your theme directory (wp-content\/themes\/theme###)<\/p>\r\n<p>2. Create new page, create new page template and assign it to the page. <\/p>\r\n<p>3. Open the created page template file<\/p>\r\n<p>4. To display a posts list we&#8217;ll use the  WordPress core tag<strong> wp_get_archives<\/strong>.<\/p>\r\n<p>This tag has several arguments:<\/p>\r\n<pre>\r\n &lt;?php $args = array(\r\n    'type'            =&gt; 'monthly',\r\n    'limit'           =&gt; ,\r\n    'format'          =&gt; 'html', \r\n    'before'          =&gt; ,\r\n    'after'           =&gt; ,\r\n    'show_post_count' =&gt; false,\r\n    'echo'            =&gt; 1 );\r\n ?&gt;\r\n<\/pre>\r\n<p>You should insert the tag into your page template file and assign necessary arguments.<\/p>\r\n<p>The following code will make your page display 20 recent posts:<\/p>\r\n<pre>\r\n\r\n&lt;?php\r\n\/*\r\nTemplate Name: Recent Posts\r\n*\/\r\n?&gt;\r\n&lt;?php get_header(); ?&gt;\r\n\t\t&lt;div class=\"container\"&gt;\r\n\t\t\t&lt;div class=\"indent\"&gt;\r\n\t\t\t\t\r\n\t\t\t\t&lt;?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?&gt;\r\n\r\n\t\t\t\t\t<strong>&lt;?php wp_get_archives('type=postbypost&amp;limit=20&amp;format=custom');\u00a0?&gt;<\/strong>\r\n\r\n\t\t\t\t&lt;?php endwhile; ?&gt;\r\n\t\t\t\t\t\r\n\t\t\t&lt;\/div&gt;\r\n\t\t&lt;\/div&gt;\r\n&lt;?php get_footer(); ?&gt;\r\n\r\n<\/pre>\r\n<p>&nbsp;<\/p>\r\n<p>Let&#8217;s see some other usage examples:<\/p>\r\n<p><strong>Display  posts for the last 12 months<\/strong><\/p>\r\n<pre>&lt;?php wp_get_archives('type=monthly&amp;limit=12');\u00a0?&gt;<\/pre>\r\n<p><strong>Display posts for the last 15 days <\/strong><\/p>\r\n<pre>&lt;?php wp_get_archives('type=daily&amp;limit=15');\u00a0?&gt;<\/pre>\r\n<p><strong>Display 20 last posts<\/strong><\/p>\r\n<pre>&lt;?php wp_get_archives('type=postbypost&amp;limit=20&amp;format=custom');\u00a0?&gt;<\/pre>\r\n<p>&nbsp;<\/p>\r\n<\/p>\r\n<\/p>\r\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>This tutorial will show you how to create a recent posts list page in WordPress. In other words you&#8217;ll learn how to create a page that will display recent posts title in a list format. Before you start this tutorial please make sure you learned how to add pages and create page templates in WordPress. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[247,728],"tags":[2564,891,893,592,892,845,2405],"_links":{"self":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/7905"}],"collection":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/comments?post=7905"}],"version-history":[{"count":2,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/7905\/revisions"}],"predecessor-version":[{"id":86011,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/posts\/7905\/revisions\/86011"}],"wp:attachment":[{"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/media?parent=7905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/categories?post=7905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.templatemonster.com\/help\/wp-json\/wp\/v2\/tags?post=7905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}