{"id":738,"date":"2008-02-11T09:22:16","date_gmt":"2008-02-11T07:22:16","guid":{"rendered":"http:\/\/planetozh.com\/blog\/2008\/02\/wordpress-snippet-complete-list-of-posts\/"},"modified":"2008-02-11T09:22:16","modified_gmt":"2008-02-11T07:22:16","slug":"wordpress-snippet-complete-list-of-posts","status":"publish","type":"post","link":"https:\/\/planetozh.com\/blog\/2008\/02\/wordpress-snippet-complete-list-of-posts\/","title":{"rendered":"WordPress Snippet: Complete List of Posts"},"content":{"rendered":"<div id=\"ig-sh-1\" class=\"syntax_hilite\">\n\n\t\t<div class=\"toolbar\">\n\n\t\t<div class=\"view-different-container\">\n\t\t\t\t\t\t<a href=\"#\" class=\"view-different\">&lt; View <span>plain text<\/span> &gt;<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t<div class=\"language-name\">php<\/div>\n\n\t\t\n\t\t<br clear=\"both\">\n\n\t<\/div>\n\t\n\t<div class=\"code\">\n\t\t<ol class=\"php\" style=\"font-family:monospace\"><li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">query_posts<span style=\"color: #009900\">&#040;<\/span><span style=\"color: #000088\">$query_string<\/span><span style=\"color: #339933\">.<\/span><span style=\"color: #0000ff\">'posts_per_page=-1'<\/span><span style=\"color: #009900\">&#041;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp;<span style=\"color: #b1b100\">while<\/span><span style=\"color: #009900\">&#040;<\/span>have_posts<span style=\"color: #009900\">&#040;<\/span><span style=\"color: #009900\">&#041;<\/span><span style=\"color: #009900\">&#041;<\/span> <span style=\"color: #009900\">&#123;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp;the_post<span style=\"color: #009900\">&#040;<\/span><span style=\"color: #009900\">&#041;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp;the_time<span style=\"color: #009900\">&#040;<\/span><span style=\"color: #009900\">&#041;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\">&nbsp; &nbsp; &nbsp; &nbsp;the_title<span style=\"color: #009900\">&#040;<\/span><span style=\"color: #009900\">&#041;<\/span><span style=\"color: #339933\">;<\/span><\/div><\/li>\n<li style=\"font-weight: normal;vertical-align:top\"><div style=\"font: normal normal 1em\/1.2em monospace;margin:0;padding:0;background:none;vertical-align:top\"><span style=\"color: #009900\">&#125;<\/span><\/div><\/li>\n<\/ol>\t<\/div>\n\n<\/div>\n\n<p>This will display the time and title for <em>all<\/em> your posts. This could result in a very long page, and a more usable way of doing  it would be to change the posts_per_page parameter, and add Next and Previous links to navigate the whole list. Code snippet by <a href=\"http:\/\/ottodestruct.com\">Otto<\/a> in the <em>wp-hackers<\/em> mailing list.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt; View plain text &gt; php query_posts&#040;$query_string.&#39;posts_per_page=-1&#39;&#041;; &nbsp; &nbsp; &nbsp; &nbsp;while&#040;have_posts&#040;&#041;&#041; &#123; &nbsp; &nbsp; &nbsp; &nbsp;the_post&#040;&#041;; &nbsp; &nbsp; &nbsp; &nbsp;the_time&#040;&#041;; &nbsp; &nbsp; &nbsp; &nbsp;the_title&#040;&#041;; &#125; This will display the time and title for all your posts. This could result in a very long page, and a more usable way of doing it would be to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[2,10,245,277,278],"class_list":["post-738","post","type-post","status-publish","format-standard","hentry","category-published","tag-code","tag-php","tag-wordpress","tag-wordpress-snippet","tag-wp-hackers"],"_links":{"self":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts\/738","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/comments?post=738"}],"version-history":[{"count":0,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts\/738\/revisions"}],"wp:attachment":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/media?parent=738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/categories?post=738"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/tags?post=738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}