{"id":116,"date":"2008-09-13T20:53:34","date_gmt":"2008-09-13T20:53:34","guid":{"rendered":"http:\/\/davstott.me.uk\/?p=116"},"modified":"2013-01-15T18:56:04","modified_gmt":"2013-01-15T18:56:04","slug":"wordpress-posts-index","status":"publish","type":"post","link":"https:\/\/davstott.me.uk\/index.php\/2008\/09\/13\/wordpress-posts-index\/","title":{"rendered":"WordPress posts index"},"content":{"rendered":"<p>This one&#8217;s more for my benefit than The Internet At Large, but I&#8217;ve just written a quick bit of php into a new wordpress page that displays an <a href=\"posts-index\/\">index of all wordpress posts<\/a> I&#8217;ve made, organised by category.  There&#8217;s a link to the index in my sidebar for when I forget where I&#8217;ve put it.  I&#8217;ve briefly fiddled with a few plugins to do this, but they were all far too verbose to be useful.  <\/p>\n<p>To be honest, the main reason I did this was to avoid having to use Google to find my own <a href=\"http:\/\/davstott.me.uk\/index.php\/2007\/10\/08\/cookies\/\">Cookies Recipe<\/a>..<\/p>\n<p>The code I&#8217;ve used is below, I&#8217;m sure some people who know more PHP than I could improve it somewhat, but it does the job. To use it yourself, just copy and paste into a new page on your wordpress site, add &lt;?php&gt; tags and a <a href=\"http:\/\/bluesome.net\/post\/2005\/08\/18\/50\/\">php execute plugin<\/a> and you&#8217;re away.<\/p>\n<p><!--more--><\/p>\n<pre>\r\n<code markup=\"none\">\r\n  $categories = get_categories('orderby=name');\r\n  foreach($categories as $thisCategory) {\r\n    $thesePosts = get_posts(array('numberposts' => -1, \r\n                                              'category' => $thisCategory->cat_ID,\r\n                                              'orderby' => 'title',\r\n                                              'order' => 'ASC'));\r\n    echo ('&lt;h2&gt;' . $thisCategory->cat_name . \"&lt;\/h2&gt;\\n\");\r\n    foreach($thesePosts as $thisPost) {\r\n      echo ('&lt;a href=\"' . get_permalink($thisPost->ID) . '\"&gt;' . \r\n              $thisPost->post_title . '&lt;\/a&gt; ('. \r\n              date('j M Y', strtotime($thisPost->post_date)) .\r\n              \")&lt;br \/&gt;\\n\");\r\n    }\r\n  }\r\n<\/code>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This one&#8217;s more for my benefit than The Internet At Large, but I&#8217;ve just written a quick bit of php into a new wordpress page that displays an index of all wordpress posts I&#8217;ve made, organised by category. There&#8217;s a link to the index in my sidebar for when I forget where I&#8217;ve put it. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-116","post","type-post","status-publish","format-standard","hentry","category-tech"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/davstott.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/davstott.me.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/davstott.me.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/davstott.me.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/davstott.me.uk\/index.php\/wp-json\/wp\/v2\/comments?post=116"}],"version-history":[{"count":15,"href":"https:\/\/davstott.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/116\/revisions"}],"predecessor-version":[{"id":129,"href":"https:\/\/davstott.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/116\/revisions\/129"}],"wp:attachment":[{"href":"https:\/\/davstott.me.uk\/index.php\/wp-json\/wp\/v2\/media?parent=116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/davstott.me.uk\/index.php\/wp-json\/wp\/v2\/categories?post=116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/davstott.me.uk\/index.php\/wp-json\/wp\/v2\/tags?post=116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}